Re: quickdie doing memory allocations (was atomic pin/unpin causing errors)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: quickdie doing memory allocations (was atomic pin/unpin causing errors)
Date: 2016-05-05 19:56:45
Message-ID: 10749.1462478205@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
>> #0 0x00000008014321d7 in sbrk () from /lib/libc.so.7
>> #1 0x0000000801431ddd in sbrk () from /lib/libc.so.7
>> #2 0x000000080142e5bb in sbrk () from /lib/libc.so.7
>> #3 0x000000080142e085 in sbrk () from /lib/libc.so.7
>> #4 0x000000080142de28 in sbrk () from /lib/libc.so.7
>> #5 0x000000080142e1cf in sbrk () from /lib/libc.so.7
>> #6 0x0000000801439815 in free () from /lib/libc.so.7
>> #7 0x000000080149e3d6 in nsdispatch () from /lib/libc.so.7
>> #8 0x00000008014a41c6 in __cxa_finalize () from /lib/libc.so.7
>> #9 0x000000080144525c in exit () from /lib/libc.so.7
>> #10 0x00000000008e1bc2 in quickdie (postgres_signal_arg=3) at postgres.c:2623
>> #11 <signal handler called>
>> #12 0x0000000801431847 in sbrk () from /lib/libc.so.7

> That looks like independent issue, namely that we're trigger memory
> allocations from a signal handler (see frames 12, 11, 10, 9). Presumably
> due to system registered atexit handlers. I suspect we should be using
> _exit() here? Tom?

I don't think that would improve matters. In the first place, if we use
_exit() here that might encourage third-party extension authors to believe
they should use _exit(), which would be bad. In the second place,
we don't know what it is we're skipping by not running atexit handlers,
and again that could be bad. We don't like people trying to bypass our
on-exit code, why would anyone else? In the third place, by the time we
get to the exit() call we've already exposed ourselves to a whole lot of
such hazards by running ereport() (including sending a message to the
client!). In the fourth place, if we've received a quickdie interrupt,
it doesn't actually matter if the process crashes; we just want it to
quit ASAP.

So I'd say that this is just a cosmetic problem and that trying to fix
it is likely to make things worse.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Seltenreich 2016-05-05 20:03:18 [sqlsmith] Failed assertion in parallel worker (ExecInitSubPlan)
Previous Message Tom Lane 2016-05-05 19:44:36 Re: Naming of new tsvector functions