From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | mikhail(at)neon(dot)tech, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18732: Segfault in pgbench on max_connections starvation |
Date: | 2024-12-03 15:27:41 |
Message-ID: | zkxk3e4eomyh2emcuwe466agbx3xuduqv2mimeaz3hqq55mwap@h4fn53tb2v6n |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hi,
On 2024-12-03 16:52:32 +0200, Heikki Linnakangas wrote:
> It looks like a race condition between OpenSSL's exit handler and the .
> HMAC_Init_ex() call in another thread. I think we could use the
> OPENSSL_INIT_NO_ATEXIT option to prevent the atexit handler from running.
> The OpenSSL man page on OPENSSL_init_crypto says:
Using exit() while another thread is running is, IIRC, undefined behaviour,
regardless of OPENSSL_INIT_NO_ATEXIT's pointlessness. The whole atexit()
mechanism is not threadsafe, two processes exit()ing at the same time can
cause a lot of havoc.
Short term it's probably easiest to just use _exit(). Medium term I think we
should just exit individual threads - which would probably require the main
thread to not run a benchmark itself.
> > By default OpenSSL will attempt to clean itself up when the process
> > exits via an "atexit" handler. Using this option suppresses that
> > behaviour. This means that the application will have to clean up
> > OpenSSL explicitly using OPENSSL_cleanup().
>
> I don't understand why that cleanup would be needed. When the program exits,
> all resources are gone anyway.
Somewhat random aside: This is also bad for postgres performance. Postmaster
initializes openssl. When a child exits, it runs - completely pointlessly -
OPENSSL_cleanup(), which modifies a lot of datastructures that have been set
up in postmaster. Which, in turn, requires all those pages to be
copy-on-write'ed. Just for that copy to immediately be discarded, at process
exit.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2024-12-03 15:42:04 | BUG #18733: Connection Timeout after upgrade |
Previous Message | Heikki Linnakangas | 2024-12-03 14:52:32 | Re: BUG #18732: Segfault in pgbench on max_connections starvation |