develooper Front page | perl.perl5.porters | Postings from August 2013

[perl #119409] DynaLoader::dl_unload_file() is unsafe with -DPERL_GLOBAL_STRUCT_PRIVATE

Nicholas Clark
August 21, 2013 19:19
[perl #119409] DynaLoader::dl_unload_file() is unsafe with -DPERL_GLOBAL_STRUCT_PRIVATE
Message ID:
# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #119409]
# in the subject line of all future correspondence about this issue. 
# <URL: >

DynaLoader::dl_unload_file() is not safe when perl was built with

This is because -DPERL_GLOBAL_STRUCT_PRIVATE uses alternative implementations
of Perl_my_cxt_init() and Perl_my_cxt_index() which store the pointer to the
extension name. For a dynamically loaded shared object this is a pointer to
memory which will be released if that shared object is unloaded, meaning that
any *other* module which calls Perl_my_cxt_index() will likely attempt a read
of unmapped memory.

I believe that -DPERL_GLOBAL_STRUCT_PRIVATE is only needed for the Symbian
port of Perl, and possibly only for some platform variants of Symbian.

I see three possible resolutions of this:

1) Replace the alternative implementation of Perl_my_cxt_index()/
   Perl_my_cxt_init() with one that does not store and compare pointers
   (eg a radix tree or similar, if we implement a useful data structure for
   some other reason)
2) De-register contexts as part of adding some more general "unload" hook
   for XS modules. (The currently missing opposite of BOOT)
3) Stall until such time as retaining the Symbian port for those devices
   needing -DPERL_GLOBAL_STRUCT_PRIVATE makes no sense.
   (ie commercial support for the last Symbian devices needing it has ended)

I don't see this as a priority to address, and have marked the tests as
todo_skip() for the problem configuration.

Nicholas Clark Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About