Date: Sat, 16 Apr 2011 14:46:31 +0300 From: Andriy Gapon <avg@FreeBSD.org> To: hackers@FreeBSD.org, freebsd-threads@FreeBSD.org Subject: puzzled: fork +libthr Message-ID: <4DA98197.8060104@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
Guys, I am trying to debug this chromium issue: http://trillian.chruetertee.ch/chromium/ticket/13 Not sure SOCK_SEQPACKET mentioned in the ticket is an actual culprit, the problem that interests me is that pthread_cond_wait() returns EPERM where it shouldn't. That happens on stable/8. I compared ktrace of chromium on stable/8 and head. Startup traces are very similar until execution gets to one particular place. At that place stable/8 chromium executes pthread_cond_wait - I see _umtx_op(UMTX_OP_CV_WAIT) and that's where EPERM is returned. On the other hand it seems that head chromium executes something different at exactly the same place, perhaps sem_wait - I see _umtx_op(UMTX_OP_WAIT_UINT_PRIVATE). So this is puzzle #1 for me why chromimum build or run-time chooses a different thing to call/use at that place. The second puzzle is the EPERM return value itself, on stable/8. >From what I seem chromium does a bunch of forks before it gets to the place of interest. My debugging shows that those forks are "single-threaded" (i.e. code in thr_fork.c is not called). And then in a process/thread that makes that pthread_cond_wait call I see that libthr and kernel have different opinions about what current TID is. Userland part uses what is actually a kernel TID of its parent thread (the one that called fork). And given how the work is divided between userland and kernel in libthr, that mismatch leads to serious consequences. So my question is why libthr doesn't see its actual TID. Maybe some initialization code is not invoked. BTW, chromium is linked to both libc and libthr (per ldd). But it seems that there are no pthread calls up the fork chain until that pthread_cond_wait call. Maybe this could ring a bell for someone knowledgeable in the area. -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DA98197.8060104>