I know this issue is closed, but for someone who needs to see the exact test case using which how this bug is reproduced by simple C test code, please find below simple C test case:
***************************** Source Code ***********************************
yogesh$ cat lib1.c
#include <stdio.h>
I know this issue is closed, but for someone who needs to see the exact test case using which how this bug is reproduced by simple C test code, please find below simple C test case: ******* ******* ******* * Source Code ******* ******* ******* ******* *******
*******
yogesh$ cat lib1.c
#include <stdio.h>
int lib1_func() ------- ------- ------- ------- ------- ----
{
return lib2_func();
}
-------
yogesh$ cat lib2.c
#include <stdio.h>
int lib2_func() ------- ------- ------- ------- ------- ----
{
return 10;
}
-------
yogesh$ cat main.c
#include <stdio.h>
#include <dlfcn.h>
#include <pthread.h>
void *handle;
static void *thread_abc()
{
handle = dlopen ("./lib1.so", RTLD_LAZY | RTLD_GLOBAL);
void *func = dlsym (handle, "lib2_func");
printf ("<thread_abc> Handle:%p, func:%p \n", handle, func);
dlclose (handle);
return NULL;
}
static void *thread_xyz()
{
handle = dlopen ("./lib1.so", RTLD_LAZY | RTLD_GLOBAL);
void *func = dlsym (handle, "lib2_func");
printf ("<thread_xyz> Handle:%p, func:%p \n", handle, func);
dlclose (handle);
return NULL;
}
int main()
pthread_ create( &abc_arr[ i], NULL, thread_abc, NULL);
pthread_ create( &xyz_arr[ i], NULL, thread_xyz, NULL);
{
pthread_t abc_arr[1000], xyz_arr[1000];
int i=0;
handle = dlopen ("./lib1.so", RTLD_LAZY | RTLD_GLOBAL);
void *func = dlsym (handle, "lib2_func");
printf ("<main> Handle:%p, func:%p \n", handle, func);
for (i=0;i<10;i++)
{
}
printf ("<main> Handle:%p, func:%p \n", handle, func);
dlclose (handle);
for (i=0;i<1000;i++)
pthread_ create( &abc_arr[ i], NULL, thread_abc, NULL);
pthread_ create( &xyz_arr[ i], NULL, thread_xyz, NULL);
pthread_ join(abc_ arr[i], NULL);
pthread_ join(xyz_ arr[i], NULL); ******* ******* ***** Compilation steps ******* ******* ******* ******* ******* ******* ******* ******* ******* ******* ******* ****
{
}
for (i=0;i<10;i++)
{
}
printf ("Returning from main\n");
return 0;
}
*******
gcc -g -fPIC -shared -o lib2.so lib2.c &&
gcc -g -fPIC -shared -o lib1.so lib1.c ./lib2.so &&
gcc -g main.c ./lib1.so ./lib2.so -ldl -lpthread
*******
With the above test case this issue is 100% reproducible.