pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Segfault in pg_stat_activity
Date: Mon, 27 Jul 2015 21:46:57 +0200
Message-ID: <20150727194657.GH5106@alap3.anarazel.de> (raw)
In-Reply-To: <20150727192033.GB11689@hjp.at>
References: <20150727192033.GB11689@hjp.at>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hi Peter, Magnus,


On 2015-07-27 21:20:33 +0200, Peter J. Holzer wrote:
> Since I've installed 9.5alpha1 a week ago, I've seen several segfaults
> in the log file:

Thanks for reporting the issue. I guess you have several ssl enabled
connections?

> Core was generated by `postgres: postgres template1 [local] SELECT                                   '.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  0x00007fb94d314289 in memcpy (__len=200, __src=0x7fb948719ad8, __dest=0x7fb94f4c1bb0) at /usr/include/x86_64-linux-gnu/bits/string3.h:51
> 51        return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
> (gdb) bt
> #0  0x00007fb94d314289 in memcpy (__len=200, __src=0x7fb948719ad8, __dest=0x7fb94f4c1bb0) at /usr/include/x86_64-linux-gnu/bits/string3.h:51
> #1  pgstat_read_current_status () at /tmp/buildd/postgresql-9.5-9.5~alpha1/build/../src/backend/postmaster/pgstat.c:3000
> #2  0x00007fb94d318db1 in pgstat_read_current_status () at /tmp/buildd/postgresql-9.5-9.5~alpha1/build/../src/backend/postmaster/pgstat.c:2434

Uh. I think I see what's going on here. Magnus, could it be that you
didn't intend the += for localsslstatus?:
		/* Only valid entries get included into the local array */
		if (localentry->backendStatus.st_procpid > 0)
		{
			BackendIdGetTransactionIds(i,
									   &localentry->backend_xid,
									   &localentry->backend_xmin);

			localentry++;
			localappname += NAMEDATALEN;
			localactivity += pgstat_track_activity_query_size;
#ifdef USE_SSL
			localsslstatus += sizeof(PgBackendSSLStatus);
#endif
			localNumBackends++;
		}

because that'll forward localsslstatus not one, but uh, something like
200.

I think just replacing the above += with 1 might fix the issue. Can't
test just now.

Greetings,

Andres Freund


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (6+ messages)  latest in thread

Message-ID: <20150727194657.GH5106@alap3.anarazel.de>
Permalink:  ../20150727194657.GH5106@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20150727194657.GH5106@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, hjp-pgsql@hjp.at, magnus@hagander.net
  Subject: Re: Segfault in pg_stat_activity
  In-Reply-To: <20150727194657.GH5106@alap3.anarazel.de>
  References: <20150727192033.GB11689@hjp.at> <20150727194657.GH5106@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox