[Asterisk-code-review] loader: support for permanent dlopen() (...asterisk[master])

Sebastian Kemper asteriskteam at digium.com
Wed Apr 3 15:42:00 CDT 2019


Hello Friendly Automation, Corey Farrell, 

I'd like you to reexamine a change. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/11217

to look at the new patch set (#2).

Change subject: loader: support for permanent dlopen()
......................................................................

loader: support for permanent dlopen()

Asterisk assumes that dlopen() will always run the constructor of a
shared library and every dlclose() will run its destructor. But dlopen()
may be permanent, meaning the constructor will only be run once, as is
the case with musl libc.

With a permanent dlopen() the Asterisk module loader does not work
correctly, because it's expectations regarding when the constructors and
destructors are run are not met. In fact a segmentation fault will occur
when the first module is "re-opened" that has AST_MODFLAG_GLOBAL_SYMBOLS
set (the dlopen() does not call the constructor, resource_being_loaded
is not set to NULL, then strlen is called with NULL instead of a string,
see issue ASTERISK-28319).

This commit adds code to the loader that will manually run the
constructors/destructors of the (non-builtin) modules where needed. To
achieve this a new ao2 container (linked list) is started and filled
with objects that contain the names of the modules and the pointers to
their respective info structs.

This behavior can be activated when configuring Asterisk
(--enable-permanent-dlopen). By default this is disabled, of course.

ASTERISK-28319 #close

Signed-off-by: Sebastian Kemper <sebastian_ml at gmx.net>
Change-Id: I86693a0ecf25d5ba81c73773a03df4abc3426875
---
M configure.ac
M main/loader.c
2 files changed, 160 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/17/11217/2
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11217
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I86693a0ecf25d5ba81c73773a03df4abc3426875
Gerrit-Change-Number: 11217
Gerrit-PatchSet: 2
Gerrit-Owner: Sebastian Kemper <sebastian_ml at gmx.net>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190403/92dd870e/attachment.html>


More information about the asterisk-code-review mailing list