Re: [BUGS] Segfault in MemoryContextAlloc

From: Dmitriy Sarafannikov <dimon99901(at)mail(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [BUGS] Segfault in MemoryContextAlloc
Date: 2016-03-11 13:03:33
Message-ID: 1457701413.865304335@f395.i.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


> Both this and the other behavior you reported sure seem like "can't
> happen" situations. I do have a theory though: I think you are doing
> something that is spawning multiple threads inside the backend, and then
> the backend logic goes nuts because it's expecting to be single-threaded.
>
> pg_buffercache wouldn't do that, and a quick google search suggests that
> V8 knows nothing of threads either. Have you got anything else going
> on in there?

I caught another segfault, which is similar to previous.
There are 2 threads and in one of this you can see libv8 functions in backtrace, and then
he was interrupted by signal.

Any ideas?

Core was generated by `postgres: xxxx xxxx x.x.x.x(58804) idle '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 MemoryContextAlloc (context=0x0, size=120) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/utils/mmgr/mcxt.c:584
584 /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/utils/mmgr/mcxt.c: No such file or directory.

(gdb) bt
#0 MemoryContextAlloc (context=0x0, size=120) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/utils/mmgr/mcxt.c:584
#1 0x00007f0e3240c4ac in AfterTriggerBeginXact () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/commands/trigger.c:3913
#2 0x00007f0e3233bea1 in StartTransaction () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/access/transam/xact.c:1848
#3 StartTransactionCommand () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/access/transam/xact.c:2534
#4 0x00007f0e32502761 in ProcessCatchupEvent () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/storage/ipc/sinval.c:337
#5 0x00007f0e32502a5d in HandleCatchupInterrupt () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/storage/ipc/sinval.c:210
#6 0x00007f0e32500c15 in procsignal_sigusr1_handler (postgres_signal_arg=<optimized out>) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/storage/ipc/procsignal.c:272
#7 <signal handler called>
#8 sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:84
#9 0x00007f0c0ef0544d in v8::internal::LinuxSemaphore::Wait (this=0x7f0c080008c0) at ../src/platform-linux.cc:880
#10 0x00007f0c0ee235d8 in v8::internal::RuntimeProfiler::WaitForSomeIsolateToEnterJS () at ../src/runtime-profiler.cc:452
#11 0x00007f0c0ee23cf8 in WaitForSomeIsolateToEnterJS () at ../src/runtime-profiler.cc:451
#12 v8::internal::RuntimeProfilerRateLimiter::SuspendIfNecessary (this=this(at)entry=0x7f0e3468672c) at ../src/runtime-profiler.cc:499
#13 0x00007f0c0ef05690 in v8::internal::SignalSender::Run (this=0x7f0e34686700) at ../src/platform-linux.cc:1160
#14 0x00007f0c0ef053a0 in v8::internal::ThreadEntry (arg=0x7f0e34686700) at ../src/platform-linux.cc:756
#15 0x00007f0e2ef570a4 in start_thread (arg=0x7f0e32820700) at pthread_create.c:309
#16 0x00007f0e305e887d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

(gdb) info threads
Id Target Id Frame
2 Thread 0x7f0e329d2740 (LWP 46202) 0x00007f0e305e972b in __libc_recv (fd=13, buf=buf(at)entry=0x7f0e32a1b140 <PqRecvBuffer>, n=n(at)entry=8192, flags=-1, flags(at)entry=0)
at ../sysdeps/unix/sysv/linux/x86_64/recv.c:33
* 1 Thread 0x7f0e32820700 (LWP 46918) MemoryContextAlloc (context=0x0, size=120) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/utils/mmgr/mcxt.c:584

(gdb) thread 2
[Switching to thread 2 (Thread 0x7f0e329d2740 (LWP 46202))]
#0 0x00007f0e305e972b in __libc_recv (fd=13, buf=buf(at)entry=0x7f0e32a1b140 <PqRecvBuffer>, n=n(at)entry=8192, flags=-1, flags(at)entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:33
33 ../sysdeps/unix/sysv/linux/x86_64/recv.c: No such file or directory.

(gdb) bt
#0 0x00007f0e305e972b in __libc_recv (fd=13, buf=buf(at)entry=0x7f0e32a1b140 <PqRecvBuffer>, n=n(at)entry=8192, flags=-1, flags(at)entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:33
#1 0x00007f0e3244c525 in recv (__flags=0, __n=8192, __buf=0x7f0e32a1b140 <PqRecvBuffer>, __fd=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/socket2.h:44
#2 secure_read (port=0x7f0e34282fe0, ptr=0x7f0e32a1b140 <PqRecvBuffer>, len=8192) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/libpq/be-secure.c:317
#3 0x00007f0e32455e40 in pq_recvbuf () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/libpq/pqcomm.c:862
#4 0x00007f0e32456bb5 in pq_getbyte () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/libpq/pqcomm.c:905
#5 0x00007f0e3251c551 in SocketBackend (inBuf=0x7ffdb8207e20) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/tcop/postgres.c:337
#6 ReadCommand (inBuf=0x7ffdb8207e20) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/tcop/postgres.c:510
#7 PostgresMain (argc=<optimized out>, argv=argv(at)entry=0x7f0e34241380, dbname=0x7f0e34241350 "xxxx", username=<optimized out>)
at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/tcop/postgres.c:4033
#8 0x00007f0e322e1b34 in BackendRun (port=0x7f0e34282fe0) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/postmaster/postmaster.c:4285
#9 BackendStartup (port=0x7f0e34282fe0) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/postmaster/postmaster.c:3948
#10 ServerLoop () at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/postmaster/postmaster.c:1679
#11 0x00007f0e324c4eab in PostmasterMain (argc=5, argv=<optimized out>) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/postmaster/postmaster.c:1287
#12 0x00007f0e322e2cd2 in main (argc=5, argv=0x7f0e34240570) at /build/postgresql-9.4-1wOG_M/postgresql-9.4-9.4.6/build/../src/backend/main/main.c:228

Thanks for advance.

--
Best regards,
Dmitriy Sarafannikov

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nick Cleaton 2016-03-11 14:12:37 Re: streaming replication master can fail to shut down
Previous Message Christian Ullrich 2016-03-11 11:49:35 Re: BUG #13854: SSPI authentication failure: wrong realm name used