This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/12307] New: accessing thread local storage blocks forever when using dlopen
- From: "maxim.yegorushkin at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Thu, 9 Dec 2010 15:12:57 +0000
- Subject: [Bug libc/12307] New: accessing thread local storage blocks forever when using dlopen
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=12307
Summary: accessing thread local storage blocks forever when
using dlopen
Product: glibc
Version: 2.12
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper.fsp@gmail.com
ReportedBy: maxim.yegorushkin@gmail.com
Description of problem:
A new thread created by a shared library initialization routine blocks forever
accessing thread local storage when the shared library is loaded during
run-time using dlopen().
Version-Release number of selected component (if applicable):
$ rpm -q glibc
glibc-2.12.1-4.x86_64
How reproducible:
Always.
Steps to Reproduce:
$ cat shared.cc
#include <cassert>
#include <pthread.h>
#include <stdio.h>
namespace {
__thread void* some_value;
void* thread(void*)
{
printf("thread enter\n");
void* value = some_value; // hangs here forever
printf("thread leave\n");
return value;
}
struct X
{
X()
{
pthread_t thread_id;
int r = pthread_create(&thread_id, NULL, thread, NULL);
assert(!r);
void* value;
r = pthread_join(thread_id, &value);
assert(!r);
}
} x;
}
$ g++ -Wall -shared -fpic -pthread -g -o shared.so shared.cc
$ cat loader.cc
#include <stdio.h>
#include <dlfcn.h>
char const shared_path[] = "./shared.so";
int main()
{
printf("loading %s\n", shared_path);
void* h = dlopen(shared_path, RTLD_NOW | RTLD_GLOBAL);
printf("%s loaded at %p\n", shared_path, h);
dlclose(h);
printf("%s unloaded\n", shared_path);
}
$ g++ -Wall -pthread -ldl -g -o loader loader.cc
Actual results:
$ ./loader
loading ./shared.so
thread enter
(the above hangs forever)
C-c C-c
Expected results:
$ ./loader
loading ./shared.so
thread enter
thread leave
./shared.so loaded at 0x7ff97355eb18
./shared.so unloaded
Additional info:
When the executable links the shared library explicitly at link time, i.e.:
$ g++ -Wall -pthread -ldl -g -o loader -l:./shared.so loader.cc
it works as expected.
P.S. It was originally filed against Fedora.
https://bugzilla.redhat.com/show_bug.cgi?id=661676
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.