[Pkg-openssl-devel] Bug#870018: Bug#870018: openssl: SIGSEGV/coredump on process stop when TLS is enabled in kamailio

Guillem Jover gjover at sipwise.com
Wed Aug 2 15:01:01 UTC 2017


Control: tags -1 patch

Hi!

On Sat, 2017-07-29 at 09:11:53 +0200, Kurt Roeckx wrote:
> On Sat, Jul 29, 2017 at 12:12:16AM +0200, Michael Prokop wrote:
> > Kurt, do you have any ideas what might go wrong in OPENSSL_cleanup
> > here and how this could be fixed? We'd appreciate any hints. Thanks!

> I don't see anything obvious wrong. From what I understand it
> calls exit(0) from a SIGTERM handler.
> 
> The only suggestion I have is that you try to run this under
> valgrind or something.
> 
> Also feel free to open a github issue about this.

I was checking this, and my initial hypothesis which I've not yet
confirmed, but seems completely spot on, given the documentation I've
just read about OPENSSL_cleanup() is that something within the pthreads
library is releasing the memory pool for the affected variable that is
segfaulting in OpenSSL, and when the OpenSSL atexit() handler gets
called the pthreads variable is already gone.

The attached patch fixes the segfault for me, and seems to be in line
with the recommendations in the OPENSSL_cleanup() docs. I should
probably update the comment further. And I guess this report should be
reassigned to the kamailio package then.

I'm not sure whether calling OPENSSL_thread_stop() would be more
correct here, as I don't know how threads are being used, and how the
TLS module interacts with the rest of the codebase, etc.

Thanks,
Guillem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openssl-pthreads-cleanup.patch
Type: text/x-diff
Size: 1456 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-openssl-devel/attachments/20170802/c26b9696/attachment.patch>


More information about the Pkg-openssl-devel mailing list