Skip to content
  • Sebastian Kemper's avatar
    ccac55b8
    loader: support for permanent dlopen() · ccac55b8
    Sebastian Kemper authored
    
    
    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: default avatarSebastian Kemper <sebastian_ml@gmx.net>
    Change-Id: I86693a0ecf25d5ba81c73773a03df4abc3426875
    ccac55b8
    loader: support for permanent dlopen()
    Sebastian Kemper authored
    
    
    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: default avatarSebastian Kemper <sebastian_ml@gmx.net>
    Change-Id: I86693a0ecf25d5ba81c73773a03df4abc3426875
Loading