Subject: Using curproc on nathanw_sa branch
To: None <tech-kern@netbsd.org>
From: Gregory McGarry <g.mcgarry@ieee.org>
List: tech-kern
Date: 01/27/2002 18:09:43
During bootstrap, curproc statically refers to &proc0. MD bootstrap code
will always run with curproc != NULL.
During bootstrap on the nathanw_sa branch, curproc statically refers
to &lwp0. MD bootstrap code will always run with curproc != NULL, and
with curproc->l_proc == NULL.
Unfortunately, there is an implicit assertion on the nathanw_sa
branch, that when curproc != NULL, then curproc->l_proc != NULL.
This isn't true for MD code which is invoked before main().
Possible solutions:
(1) simultaneously check for (curproc != NULL) && (curproc->l_proc != NULL)
in MD code;
(2) statically set curproc = NULL during bootstrap; or
(3) nuke all references to curproc from MD code.
I'm not sure what the implications of option (2) are. I believe
that the use of curproc has escaped beyond its original intention.
Certainly, there are many unnecessary uses of curproc in MD code which
can be removed. But I'm not sure option (3) is realistic.
A pathological example is to boot into ddb to get a stacktrace and set
some breakpoints. This example doesn't expose the problem on all ports
though.
-- Gregory McGarry <g.mcgarry@ieee.org>