Date: Thu, 8 Jul 1999 12:50:02 -0700 (PDT) From: Jin Guojun <j_guojun@lbl.gov> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/11984: pthread_kill cannot kill select() threads, etc. Message-ID: <199907081950.MAA47981@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/11984; it has been noted by GNATS. From: Jin Guojun <j_guojun@lbl.gov> To: freebsd-gnats-submit@freebsd.org, jin@iss-p1.lbl.gov Cc: Subject: Re: kern/11984: pthread_kill cannot kill select() threads, etc. Date: Thu, 08 Jul 1999 12:46:56 -0700 By tracing downto c_r library, two problems have been found: (1) pthread_exit(void *status) { int sig; long l; pthread_t pthread; /* Check if this thread is already in the process of exiting: */ if ((_thread_run->flags & PTHREAD_EXITING) != 0) { char msg[128]; snprintf(msg,"Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run); PANIC(msg); } /* Flag this thread as exiting: */ _thread_run->flags |= PTHREAD_EXITING; ... } PTHREAD_EXITING is defined as 0x100, but _thread_run->flags is type of char. So, PTHREAD_EXITING can never be checked or set. (2) _thread_gc(pthread_addr_t arg) { .... /* * Check if this is not the last thread and there is no * memory to free this time around. */ if (!f_done && p_stack == NULL && pthread_cln == NULL) { /* Get the current time. * * Note that we can't use clock_gettime(2) on 2.2.x; * use gettimeofday(2) instead. */ struct timeval abstimeval; if (gettimeofday(&abstimeval, NULL) != 0) PANIC("gc cannot get time"); TIMEVAL_TO_TIMESPEC(&abstimeval, &abstime); /* * Do a backup poll in 10 seconds if no threads * die before then. */ abstime.tv_sec += 10; /* * Wait for a signal from a dying thread or a * timeout (for a backup poll). */ /* Line 215 */ if ((ret = pthread_cond_timedwait(&_gc_cond, &_gc_mutex, &abstime)) != 0 && ret != ETIMEDOUT) PANIC("gc cannot wait for a signal"); } /* Unlock the garbage collector mutex: */ if (pthread_mutex_unlock(&_gc_mutex) != 0) PANIC("Cannot unlock gc mutex"); ... } Line 215, dying thread will not able to give conditional signal to gc thread, so the pthread_exit() hang forever. Fixing: unknown -- it seems to me this logic needs to be tuned. Working around: force gc exit(0) if timeout; but this is a temp solution. -Jin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907081950.MAA47981>