Subject: Re: serious bug introduced in Linux compatibility
To: Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
From: Jaromír <jdolecek@netbsd.org>
List: tech-kern
Date: 03/24/2001 12:31:49
Emmanuel Dreyfus wrote:
> Ok, this is the problem. I did not expect vmspace to be invalid when I
> wrote ths brk() fix.

It's not totally obvious the vmspace is not yet setup when the fork
hook is run.

> In the meantime, shouldn't we bracket the brk() fix in linux_exec.c with
> an #ifdef notyet?
> This fix enabled java to run on the PowerPC, but it seems it broke lot
> of things on other ports.

Only remaining is fix to DTRT WRT threads, which is much less severe.
I think it may stay this way if the fix would not take too long.

> Do you already have an idea for this?

Just hook up additional struct from p_emuldata via a pointer, which
would contain the brk value and usage counter (and a spin lock
probably, too). Share the struct between threads, increase counter
on fork(), decrease on exec(), g/c when counter reaches zero. Only
share the struct if vmspace is to be shared with parent process
(this needs interface change to e_proc_fork() hook, so that 
the fork1() flags are passed down to the hook).

Some care needs to be taken to guard modifications to the brk
value against concurrent access.

It's all pretty streightforward thing to do, see e.g. like the
vmspace is shared, or sigacts are shared within sigctx, or p->p_fd.

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
 ***  Wanna a real operating system ? Go and get NetBSD, dammit!  ***