[Bug nptl/10919] New: pthread_cancel segfault when used in shared library

View: New views
3 Messages — Rating Filter:   Alert me  

[Bug nptl/10919] New: pthread_cancel segfault when used in shared library

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

[Bug nptl/10919] pthread_cancel segfault when used in shared library

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From fhol at gmx dot at  2009-11-08 16:22 -------
Created an attachment (id=4368)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4368&action=view)
short application to show the problem


--


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.

[Bug nptl/10919] pthread_cancel segfault when used in shared library

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From drepper at redhat dot com  2009-11-19 17:54 -------
I see no problem.  The program terminates normally.  Report this to your
distribution maker.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


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.