[PATCH][BZ #11941] Fix spurious assert in dlclose.
Carlos O'Donell
carlos@redhat.com
Fri Nov 8 03:04:00 GMT 2013
On 11/06/2013 08:58 AM, OndÅej BÃlka wrote:
> On Thu, Oct 31, 2013 at 03:36:48PM -0400, Carlos O'Donell wrote:
>> On 10/26/2013 03:37 AM, OndÅej BÃlka wrote:
>>> Hi, in following bug we did represent that destructor was called by reseting
>>> l_init_called to zero. This triggered a assert in dlclose.
>>>
>>> A solution would be add additional l_fini_called flag to represent this
>>> condition.
>>>
>>> [BZ #11941]
>>> include/link.h (struct link_map): Add l_fini_called.
>>> elf/dl-fini.c (_dl_fini): Guard double call by l_fini_called
>>> instead of reseting l_init_called.
>>
>> Thanks for fixing this.
>>
>> This looks good to me, but we need a test case before we can check this in.
>>
> I tried to write a self contained testcase but did not succeed.
> A bug report is about pstoedit program so some additional constaints are
> needed.
>
> I tried following as a closest match to bug description but it works as
> intended.
>
> #include <unistd.h>
> #include <dlfcn.h>
> struct dl
> {
> void *handle;
> dl (void)
> {
> handle = dlopen("./x.so", RTLD_NOW);
> }
> ~dl (void)
> {
> dlclose (handle);
> }
> };
>
> dl d;
>
> int main()
> {
> char *args[2] = {"/bin/ls", "foo"};
> execvp ("/bin/ls", args);
> }
>
Then I think we need to spend more time trying to understand exactly
how the code is wrong and how we trigger it. It should be entirely
possible to trigger such asserts. I know it's hard work, but writing
test cases are really where the rubber hits the road (I just spent
almost a day writing one for the ppc64 opd ifunc failure Azanella
just posted a patch for).
Cheers,
Carlos.
More information about the Libc-alpha
mailing list