Subject: COMPAT_MACH and lwp
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: tech-kern
Date: 01/26/2003 14:40:36
Hello everybody

I have trouble debugging the new COMPAT_MACH threading, now that we use lwp.

In sys/compat/mach/macg_thread.c:mach_thread_create_running()
we do this:

        if ((error = newlwp(l, l->l_proc, uaddr, inmem, flags, NULL, 0,
            mach_create_thread_child, (void *)&mctc, &mctc.mctc_lwp)) != 0)
                return mach_msg_error(args, error);

But mach_create_thread_child is never executed (I have a debug printf at the
beginning of the function). I checked
sys/arch/powerpc/powerpc/vm_machdep.c:cpu_lwp_fork() and when we do this

        cf->r31 = (register_t)func;

func is mach_create_thread_child, I checked this with a debug printf. So the
child is supposed to go in mach_create_thread_child.

Here is a ps -axsww output for the threads:

UID PID PPID CPU LID NLWP PRI NI VSZ  RSS WCHAN    STAT TT    TIME COMMAND
500 358  347   0   2    2  28  0  20 1548 -        R    p0 0:02.50
/emul/darwin/test/pth_create 
500 358  347   0   1    2   0  0  20 1548 mach_thr S    p0 0:02.50
/emul/darwin/test/pth_create 

Parent is sleeping, awaiting for the child to be ready, and I have no idea
where the child is. It is supposed to be runnable, but according to TIME, it
has nor run.

If I try to kill the child, I get this:
panic: proc_stop: process 358 lwp 2 in unstoppable state 1.

Anyone has an idea of what could be wrong?

-- 
Emmanuel Dreyfus
manu@netbsd.org