[RFC][PATCH v1 5/5] elf/dl-fini.c: Handle cloned link_map entries in the shutdown path
Vivek Das Mohapatra
vivek@collabora.com
Fri May 18 19:25:00 GMT 2018
>> --- a/elf/dl-fini.c
>> +++ b/elf/dl-fini.c
>> @@ -24,6 +24,50 @@
>> /* Type of the constructor functions. */
>> typedef void (*fini_t) (void);
>>
>> +/* Remove (and free) cloned entries from the namespace specifid by `ns'. */
>> +void
>> +_dl_forget_clones (Lmid_t ns)
>> +{
>> +#ifdef SHARED /* Obviously none of this applies if */
>
> Move the #ifdef up to the caller please.
I think it was there originally but when I was building the
full suite (including the static variant) gcc got upset at me
about the bounds checking of GL(dl_ns)[â¦]. I'll revisit it
and see if I can figure out what the problem was.
>> + /* We need to remove any pointers to cloned entries (link_map
>> + structs that are copied from one namespace to another to
>> + implement RTLD_SHARED semantics) before the regular cleanup
>> + code gets to them. */
>> + _dl_forget_clones (ns);
>
> While this is easy to implement like this, I think we are going to run
> into use cases where this doesn't work.
>
> Consider this test case:
>
> - Only a fini in a library.
> - Lazy binding.
> - fini calls a libc.so.6 function for the first time.
> - When fini is called we jump into ld.so to find the symbol to call,
> but the libc.so.6 proxy has been removed, and so we can no longer
> resolve calls to it.
> You will, IMO, have to remove the proxies at the point the library
> would have been unloaded normally from the namespace, but avoid doing
> all the other work.
Hm. Ok, I'll get on that.
>> +
>> unsigned int nloaded = GL(dl_ns)[ns]._ns_nloaded;
>> /* No need to do anything for empty namespaces or those used for
>> auditing DSOs. */
>>
>
> In summary I think we need a v2 of this patch which implements a more complex
> free-at-unload support.
Right. I will work through this and the other changes, hopefully a new patchset
should land next week.
More information about the Libc-alpha
mailing list