[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#37604: The bug only occurs if the same library is opened twice.

For clarification, the bug only happens if the same library is opened
twice.  Since dlopen() will only open each library once, I assumed it
cached the fact that it had already mostly-opened the library (just
failed to resolve symbols) somewhere, then returned the cached pointer
to its internal structures without noting that the library had really
failed to link.

As an example of this problem:
	I have a.so that has an undefined symbol (int a) referenced in
it.  I have a program b.c that is as follows:
#include <dlfcn.h>
#include <stdio.h>

int a;		/* the 'int a' to be refered to by a.so */

int main(void) {
	void *x=dlopen("a.so",RTLD_NOW|RTLD_GLOBAL);
	void *foo;
	if (!x)
		return -1;

That program works great if I compile it correctly:
	gcc -rdynamic -o b b.c -ldl
but if I forget the -rdynamic then the symbol 'a' never gets resolved
and the bug shows up.
	Sorry for the misleading report earlier.  I was searching
directories in a list and it took me a while to determine that the bug
only showed up when that path was in the list twice.

Reply to: