https://bugzilla.novell.com/show_bug.cgi?id=289641 Summary: lock-up on Qt app exit from g++ miscompiling pthread cleanup code Product: openSUSE 10.2 Version: Final Platform: i686 OS/Version: openSUSE 10.2 Status: NEW Severity: Normal Priority: P5 - None Component: Development AssignedTo: pth@novell.com ReportedBy: ahanssen@trolltech.com QAContact: qa@suse.de Found By: Other The program from the source code below locks up if compiled with gcc or g++ with exceptions disabled, but locks up when compiled with g++ with exception support enabled. If you look in pthread.h, you'll see the cleanup handler code is different when compiling for C or C++. Effect: All Qt 4 applications can lock up on exit. Why: Qt's QThread class uses pthread's cleanup handlers to get notifications for when threads die on Unix. Because of what seems to be a gcc bug, this cleanup handler is not called on OpenSuSE 10.2. We have tested the same compiler version on other distributions, and it doesn't lock up there. Also, Intel's ICC does not cause this lockup. Compiler version: gcc (GCC) 4.1.2 20061115 (prerelease) (SUSE Linux) To compile as C: gcc main.c -lpthread as C++: g++ main.c -lpthread as C++: g++ main.c -lpthread -fno-exceptions ---8<--- #include <pthread.h> #include <stdio.h> #include <unistd.h> pthread_cond_t cond = PTHREAD_COND_INITIALIZER; void finish(void *arg) { pthread_cond_signal(&cond); fprintf(stderr, "finish()\n"); } void *cancelthread(void *arg) { pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_cleanup_push(finish, NULL); fprintf(stderr, "thread sleeping...\n"); pthread_testcancel(); sleep(300); pthread_cleanup_pop(1); return 0; } int main() { pthread_attr_t attr; pthread_t thread2; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&thread2, &attr, cancelthread, NULL); sleep(1); fprintf(stderr, "request cancel\n"); pthread_cancel(thread2); fprintf(stderr, "wait\n"); pthread_cond_wait(&cond, &mutex); fprintf(stderr, "done\n"); } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.