This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/10919] New: pthread_cancel segfault when used in shared library
- From: "fhol at gmx dot at" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Nov 2009 16:20:32 -0000
- Subject: [Bug nptl/10919] New: pthread_cancel segfault when used in shared library
- Reply-to: sourceware-bugzilla at sourceware dot org
There is a problem with thread cancellation, stack unwinding and shared
libraries. (Tested on Ubuntu 8.10 with gcc 4.3.2-1ubuntu12, libc-2.8.90.so and
Ubuntu 7.10.)
If pthread_cancel is called in the library, a segmentation fault occurs. For
static linkage the problem does not occur and the thread is canceled as expected.
In the attachment you can find a demo application reproducing the problem. It
consists of an Makefile and the source files:
main.cpp
thread_test_lib.h - library interface
thread_test_lib.cpp - library source
If you invoke make the shared library libthread_test_lib.so and the application
thread_test are built. Make also generates thread_test_static which is the same
application, but statically linked.
The library provides the functions thread_setup() to create an internal task and
thread_cleanup() to cancel the task.
When thread_test is executed a segmentation fault occurs:
./thread_test
thread_setup()
run_thread::task() started
thread_cleanup()
Segmentation fault (core dumped)
According to the core dump the segmentation fault is inside task().
It can be observed that no segmentation fault occurs for one of the following
conditions:
- ./thread_test_static is called instead of ./thread_test
- the line "std::string s..." inside task() (see thread_test_lib.cpp) is
commented out
- usleep() in task() is replaced by sleep() or pthread_testcancel
- usleep() in task() is called indirectly via a wrapper function
--
Summary: pthread_cancel segfault when used in shared library
Product: glibc
Version: 2.8
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: fhol at gmx dot at
CC: glibc-bugs at sources dot redhat dot com
GCC host triplet: i686-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=10919
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.