fa.openbsd.tech
[Top] [All Lists]

Re: Fix race in rthreads join/exit

Subject: Re: Fix race in rthreads join/exit
From: Vadim Zhukov <persgray@xxxxxxxxx>
Date: Fri, 25 Jul 2008 12:13:44 UTC
Newsgroups: fa.openbsd.tech

7 July 2008 c. 20:57:14 Vadim Zhukov wrote:
> 29 June 2008 c. 03:32:56 Philip Guenther wrote:
> > Eliminate a race-condition between pthread_join() and pthread_exit()
> > by using the spinlock inside the thread's "donesem" to protect the
> > thread's flags and making the waiting and posting on the semaphore
> > atomic with the unlocking of the spinlock.
> >
> > This also makes pthread_join() with a NULL pthread_t return EINVAL
> > instead of crashing, as a courtesy to poorly written apps.
>
> I tried to find a test case in the base, and found ico(1) from X set.
> Maybe I did something stupid or this program is erroneous, but it
> crashes at startup in rfork_thread() when I try to use
> librthread.so.2.0 instead of libpthread.so.11.0 (symlink made in
> /usr/lib):
>
> #0  0x04a89235 in rfork_thread () from /usr/lib/libpthread.so.11.0
> #1  0x04a8783c in pthread_create (threadp=0x85f2e300, attr=0x24a8521c,
> start_routine=0x85f2e300, arg=0x85f2e300) at rthread.c:317
> #2  0x1c003e79 in main (argc=0, argv=0xcfbca1c8) at
> /usr/xenocara/app/ico/ico.c:1317
>
> I'm not a ddb-specialist. I'll say more: I'm a ddb-lamer. If I there
> should be any more information then I, of course, will give it; but I
> think it'll be reproducable not only on my PC (with both MP and UP
> kernels tested).
>
> Of course, kernels were built with RTHREADS option.

I recompiled librthread with "-O0", and it somehow worked: ico(1) and
ysm(1) (from ports) work. But I cannot shutdown X properly, it hangs the
whole system.

Again, libthread works flawlessly on another PC, where I run squid - no
troubles seen so far at all.

--
  Best wishes,
    Vadim Zhukov


<Prev in Thread] Current Thread [Next in Thread>