segfault after cleanup handler
"Hahn, Karsten" <[email protected]>
| Newsgroups | gmane.linux.ngpt.devel |
|---|---|
| Organization | Comsoft GmbH |
| Message-ID | <[email protected]> |
Hello, I had a strange problem with ngpt 2.0.1, linux kernel 2.4.19 (futex-patch applied), glibc 2.2.5 and gcc-3.2. In my tests of a larger application I got segmentation faults in the function pth_pqueue_Qinsert() in pth_pqueue.c when pthread_cancel()-ing a thread. The canceled thread called its pthread_cleanup-handler and exits (as far as I can tell) normally. But ngpt throws (sometimes!) a segfault, if pthread_cancel() was called before in the application. After looking into the problem I came up with a little patch which solves my problem, but I'm not sure if there are any side-effects. Regards, Karsten -- Karsten Hahn Phone: +49 721 9497-241 COMSOFT GmbH Fax: +49 721 9497-129 Wachhausstr. 5a http://www.comsoft.de D-76227 Karlsruhe, Germany mailto: [email protected]
patch_pth_pqueue
(text/x-diff, 468 B)
--- pth_pqueue.c.orig Wed Aug 21 13:20:32 2002
+++ pth_pqueue.c Wed Aug 21 13:22:49 2002
@@ -62,6 +62,4 @@
intern void pth_pqueue_Qinsert(pth_pqueue_t *q, int prio, pth_t t)
{
- pth_t c = NULL;
-
if (q == NULL)
return;
@@ -77,7 +75,6 @@
q->q_num++;
} else if (prio == 0) {
- c = q->q_head->q_prev;
- t->q_prev = c;
- t->q_next = c->q_next;
+ t->q_prev = q->q_head->q_prev;
+ t->q_next = q->q_head;
t->q_prev->q_next = t;
t->q_next->q_prev = t;