Re: [BUG] Re-entering malloc problem when use --enable-nls build postgresql

From: Andres Freund <andres(at)anarazel(dot)de>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 158306855 <anderson2013(at)qq(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: [BUG] Re-entering malloc problem when use --enable-nls build postgresql
Date: 2018-05-08 21:40:52
Message-ID: 20180508214052.3u2um6s2sl3nchjw@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2018-05-09 09:30:58 +1200, Thomas Munro wrote:
> On Wed, May 9, 2018 at 7:51 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > On 2018-05-08 01:36:31 -0700, Andres Freund wrote:
> >> On 2018-05-08 02:07:08 -0400, Tom Lane wrote:
> >> > To stderr, maybe. Across an SSL-encrypted client connection? You're
> >> > dreaming.
> >>
> >> libpq invents an equivalent message when the server closes the
> >> connection anyway, IIRC. So that'd not necessarily be too bad.
> >
> > Oh, also: It looks like it'd actually be relatively easy to give openssl
> > its own memory allocator + pool:
> > Create a global 'openssl' memory context with preallocation, use
> > CRYPTO_set_mem_functions() to make openssl allocations go through small
> > wrapper functions around palloc/repalloc/pfree.
> >
> > It's still not entirely kosher to call into openssl from a signal
> > handler because we could be inside openssl - but the window for that is
> > a lot smaller than being inside *any* memory allocation.
>
> Can't we use a more traditional signal handling style to defer
> execution here? 1. Set an in_OpenSSL flag whenever you're about to
> enter OpenSSL. 2. In the SIGQUIT handler, if you find that flag is
> set, then just set got_SIGQUIT and return. 3. After you leave the
> OpenSSL code, if you see got_SIGQUIT, then run the handler explicitly.

Well, the question is if that'd ever have us defer killing the process
for longer. quickdie is intended to actually die quickly. If there's
rekeying, a large COPY incoming, or something like that it could take a
bit. Aren't there also still places where we do blocking network IO?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-05-08 22:04:07 Re: [BUG] Re-entering malloc problem when use --enable-nls build postgresql
Previous Message Thomas Munro 2018-05-08 21:30:58 Re: [BUG] Re-entering malloc problem when use --enable-nls build postgresql