Subject: Re: lib/36011 (pthread library causes a crash with puffs/dtfs)
To: None <ad@NetBSD.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org,>
From: None <pooka@netbsd.org>
List: netbsd-bugs
Date: 05/10/2007 12:37:36
Synopsis: pthread library causes a crash with puffs/dtfs

State-Changed-From-To: open->analyzed
State-Changed-By: pooka@netbsd.org
State-Changed-When: Thu, 10 May 2007 15:37:34 +0300
State-Changed-Why:
Ok, so the problem was pretty obvious after looking at the stacktrace
for more than two seconds.  Since the continuations run on alternate
stacks, the main thread init routine doesn't know about them.  The
malloc mutex lock tries to figure out which thread it is and fails,
since there is no pthread for the continuation stack.

I'm not quite sure how these could be made to play together.  One
possibility would be to give the continuations in a threaded program
a real pthread_t so that pthread_self() would work, but just don't
introduce them to the scheduler as such.  I don't know enough about
our libpthread internals to judge how easy that would be to do.

However, it is now possible to run threaded programs if they don't
puffs_cc_yield()/puffs_cc_continue(), IOW ones which block until 
the request has been satisfied.  Multiple threads for requests
dispatching are not safe, since libpuffs isn't threadsafe.  To
enable the kludge, do
extern int puffs_fakecc;
puffs_fakecc = 1;