This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/5931] New: pthread_cleanup_push does not work with -fno-exceptions


This is a simple C++ program:

#include <cstdio>
#include <pthread.h>

void
cancel (void *)
{
  std::printf ("in cancel\n");
}

int
main (int, char**)
{
  pthread_cleanup_push (cancel, NULL);
  std::printf ("after pthread_cleanup_push\n");
  pthread_cleanup_pop (0);
  std::printf ("after pthread_cleanup_pop\n");
}

I compiled it on an x86 system running Fedora 7.  It worked fine.

However, when I compiled it like this:

g++ -o foo foo.cc -fno-exceptions

I get this:

/tmp/ccyhckFj.o: In function `main':
/home/iant/foo.cc:13: undefined reference to `__pthread_register_cancel'
/home/iant/foo.cc:15: undefined reference to `__pthread_unregister_cancel'

Looking at pthread.h, I see that pthread_cleanup_push has a different definition
when -fno-exceptions is used.  That definition has an explicit call to
__pthread_register_cancel.  Unfortunately, the symbol __pthread_register_cancel
is not defined by libpthread.so.  The function is defined in nptl/cleanup.c, and
is marked as hidden, so it can not be called from outside the shared library.

I think that either the functions __pthread_register_cancel and
__pthread_unregister_cancel have to be made visible, or the definition of
pthread_cleanup_push when __EXCEPTIONS is not defined has to change.

A similar program written in C fails in the same way.  When I explicitly pass
-fexceptions to the C compiler, it fails with undefined references to
__pthread_cleanup_routine.

-- 
           Summary: pthread_cleanup_push does not work with -fno-exceptions
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: ian at airs dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=5931

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]