Re: Segfault in pg_stat_activity

From: Andres Freund <andres(at)anarazel(dot)de>
To: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Segfault in pg_stat_activity
Date: 2015-07-27 19:46:57
Message-ID: 20150727194657.GH5106@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fabien COELHO 2015-07-27 21:04:33 Re: BUG #13442: ISBN doesn't always roundtrip with text
Previous Message Tom Lane 2015-07-27 19:42:29 Re: Segfault in pg_stat_activity