Another interesting point. If I copy test/pthread/cancellation-points.c to test/pthread/cancellation-points.cpp and make a few tweaks to get it to compile, most of the tests fail because the functions they are testing don't have .eh_frame information.
Al On Fri, Feb 24, 2012 at 3:04 PM, Alan Cooper <[email protected]> wrote: > Here's the C++ test program I used. This tests both > pthread_cleanup_push/pop and the fact that the cancelled threads > locally scoped class destructors should be called on cancel. > > #include <pthread.h> > #include <stdio.h> > #include <unistd.h> > #include <stdlib.h> > > > int cleanup_ok; > int unwind_ok; > > class test_class > { > public: > test_class(void) { printf("TEST CLASS CONSTRUCTOR\n");}; > ~test_class() { printf("TEST CLASS DESTRUCTOR\n"); unwind_ok=1; }; > }; > > > void cleanupHandler(void *arg) > { > printf("In the cleanup handler\n"); > cleanup_ok = 1; > } > > void *threadfunc(void *parm) > { > > printf("Entered secondary thread\n"); > pthread_cleanup_push(cleanupHandler, NULL); > do { > class test_class testt; > > while (1) { > pthread_testcancel(); > sleep(1); > } > } while(0); > printf("pthread_cleanup_pop\n"); > pthread_cleanup_pop(0); > return NULL; > } > > int main(int argc, char **argv) > { > pthread_t thread; > int rc=0; > > printf("Enter Testcase - %s\n", argv[0]); > > /* Create a thread using default attributes */ > printf("Create thread using the NULL attributes\n"); > rc = pthread_create(&thread, NULL, threadfunc, NULL); > > /* sleep() isn't a very robust way to wait for the thread */ > sleep(2); > > printf("Cancel the thread\n"); > rc = pthread_cancel(thread); > > rc = pthread_join(thread, (void **)&rc); > printf("Test completed\n"); > printf("pthread_cleanup_push/pop: %s\n", cleanup_ok ? "PASSED" : > "FAILED"); > printf("unwind called destructors: %s\n", unwind_ok ? "PASSED" : > "FAILED"); > return 0; > } > > > > > > > On Fri, Feb 24, 2012 at 2:28 PM, Bernhard Reutner-Fischer > <[email protected]> wrote: >> On Feb 24, 2012 6:26 PM, "Alan Cooper" <[email protected]> wrote: >>> >>> I'm having a problem with a C++ program where the the >>> pthread_cleanup_push cleanup routine is not being called when the >>> thread is cancelled. This is happening because class destructors are >>> not being called by the exception unwind routine. I found the problem >>> to be caused by the fact that some of the system calls that are >>> cancellation points, in this case sleep(), don't have the .eh_frame >>> info needed to unwind the stack frames and break the unwind chain. I >>> see that the CFLAGS for some modules have -fexceptions set, which will >>> cause the .eh_frame to be generated, but this flag is not set for all >>> the standard Linux defined cancellation points. Am I missing something >>> here or has this always been broken? >> >> Do you have a small testcase? This may be fixed on the future branch >> already.. >>> >>> Thanks >>> Al Cooper >>> _______________________________________________ >>> uClibc mailing list >>> [email protected] >>> http://lists.busybox.net/mailman/listinfo/uclibc _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
