[Bug c/39130] New: [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening
Freshly compiled code calls and excutes a function in a non-existent library. Details below : #gcc -v gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) How to reproduce the problem : #Directories required "./shared" #source code head'ed below ==> 1.c <== #include void fun() { printf("1\n"); } ==> 2.c <== #include void fun() { printf("2\n"); } #include #include int main(int argc, char **argv) { void *lib_handle; void (*fn)(); char *error; while(1) { lib_handle = dlopen("./shared/libkali.so", RTLD_LAZY); if (!lib_handle) { fprintf(stderr, "%s\n", dlerror()); exit(1); } fn = dlsym(lib_handle, "fun"); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); exit(1); } (*fn)(); dlclose(lib_handle); }//while return 0; } #gcc -Wall -fPIC -c 1.c #gcc -Wall -fPIC -c 2.c #gcc -shared -Wl,-soname,lib1.so.1 -o lib1.so.1.0 1.o #gcc -shared -Wl,-soname,lib2.so.1 -o lib2.so.1.0 2.o #gcc -rdynamic -o progdl progdl.c -ldl #Following shared library will be changed to test plug-in (lib1.so.1.0 or lib2.so.1.0) #ln -sf `pwd`/lib1.so.1.0 shared/libkali.so; ln -sf `pwd`/lib1.so.1.0 shared/libkali.so.1 #ln -sf `pwd`/lib2.so.1.0 shared/libkali.so; ln -sf `pwd`/lib2.so.1.0 shared/libkali.so.1 -- Summary: [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ykalidas at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39130
[Bug c/39130] [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening
--- Comment #1 from ykalidas at gmail dot com 2009-02-08 06:29 --- Created an attachment (id=17271) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17271&action=view) Plug-in function void fun(); is a function that would be made available through a shared object. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39130
[Bug c/39130] [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening
--- Comment #2 from ykalidas at gmail dot com 2009-02-08 06:29 --- Created an attachment (id=17272) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17272&action=view) Plug-in function void fun(); would be made available through a shared object. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39130
[Bug c/39130] [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening
--- Comment #3 from ykalidas at gmail dot com 2009-02-08 06:30 --- Created an attachment (id=17273) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17273&action=view) program invoking shared lib's function. Program that loads the function in the shared library. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39130
[Bug c/39130] [libdl] (Now and then) dynamic loading/un-loading of shared libraries not happening
--- Comment #4 from ykalidas at gmail dot com 2009-02-08 06:47 --- PROBLEM - when i change the libkali.so.1 and libkali.so in ./shared/ to point to either of the libraries lib1.so.1.0 or lib2.so.1.0, the program run only one of the codes to which it pointed earlier. Example #ln -sf `pwd`/lib1.so.1.0 shared/libkali.so; ln -sf `pwd`/lib1.so.1.0 shared/libkali.so.1 #./progdl would STILL INVOKE fun() in lib2.so.1.0 EVEN IF THE FILE IS REMOVED. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39130