This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #11941] Fix spurious assert in dlclose.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Carlos O'Donell <carlos at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 6 Nov 2013 14:58:49 +0100
- Subject: Re: [PATCH][BZ #11941] Fix spurious assert in dlclose.
- Authentication-results: sourceware.org; auth=none
- References: <20131026073726 dot GA15095 at domone dot podge> <5272B150 dot 7050204 at redhat dot com>
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);
}