tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Anomalies while handling p_nstopchild count



The attached patch should handle this.  It takes out the proc_lock and
then updates the process's p_stat, p_waited, and parent's p_nstopchild
with the lock held.  It then releases the lock.

In the normal exit case, it reacquires the lock and restores p_stat to
its previous value (which almost certainly is SACTIVE, since that's
the value that do_posix_spawn() set, before dispatching the new lwd
for scheduling).

In the several error cases, we go to a new error-exit code where we
again reacquire proc_lock and restore p_stat and p_nstopchild before
continuing with the rest of the error path.

Note that this change has the effect of restoring p_stat in the error
branch.  This should not be an issue, since the error code will very
soon call exit1() where the process will be properly disposed.

Note that I have not tested this patch yet, not even compile-test. I
would appreciate additional eyes to review this.

:)

Updated patch attached.  This one compiles, and I added a KASSERT on
the value of ostat (original p_stat) before updating it.

I have recorded this in PR kern/50330 for this.  I will request
pull-ups to -6 and -7.  The posix_spawn code doesn't exist in -5 so
no need to pullup there.



+------------------+--------------------------+-------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
+------------------+--------------------------+-------------------------+


Home | Main Index | Thread Index | Old Index