OSDN Git Service

Don't call dlsym from signal context in signal chain
authorDave Allison <dallison@google.com>
Tue, 16 Sep 2014 17:01:01 +0000 (10:01 -0700)
committerDave Allison <dallison@google.com>
Tue, 16 Sep 2014 17:11:17 +0000 (10:11 -0700)
commitcefcea838729287a04174664a76514dd793dd77d
tree1feb269b6224d0448f15502eb09da4a97dc67b24
parent5733b35c23792834f3a2374003c109301a48867c
Don't call dlsym from signal context in signal chain

It is dangerous to call dlsym from within a signal context
since it takes a lock and can lead to a mutex reentry attempt if
timing is bad.

This change adds an initialization function to the signal chain
that calls dlsym for sigaction and sigprocmask from outside the
signal context (from Runtime::Init()).  The results are cached
in a static variable and used from within the signal context if
necessary.

However, tests don't necessarily call Runtime::Init() so we also
need to deal with the case where the signal chain is not initialized
and perform a lazy initialization from inside sigaction or sigprocmask.
This is always outside a signal context since we have not initialized
the runtime.

Bug: 17498571
Change-Id: I59eebfc67cc91c6f1d781a73e5d432ca5269ee48
runtime/runtime.cc
sigchainlib/sigchain.cc
sigchainlib/sigchain.h