Subject: Re: KDASSERT(sa->sa_nstacks > 0); in sa_upcall_userret(struct lwp *l)
To: Nathan J. Williams <>
From: Lars Heidieker <>
List: current-users
Date: 02/10/2003 21:07:29
I have seen one system panic under very high memory pressure,
top showed only 20k free.
First I saw some "sa_switch(%d.%d flag %x): Not enough stacks." messages
and shortly after that the system paniced,
so there had to be a possibility of changing the stack count
between the while loop and the the assertion.
I did the same I moved the sadata_upcall_alloc() above the while loop.
I never saw the assertion firing again, but I have seen a
printf("sa_switch(%d.%d): no cached LWP for upcall.\n" message on a
non-smp machine and thats currently giving me something to think about.
(I'll try to reproduce that one again)


"Nathan J. Williams" wrote:

> Lars Heidieker <> writes:
> > in the function sa_upcall_userret(struct lwp *l) / kern_sa.c there
> > is a slight chance getting the KDASSERT(sa->sa_nstacks > 0); kicking
> > in as after the "while (sa->sa_nstacks == 0)" loop checking the
> > condtion tested in the assertion there is a chance of sleeping (sau
> > = sadata_upcall_alloc(1);) so under extrem memroy pressure the
> > system might panic (or later crash without the assertion)
> Yes, I belive you are correct. I have moved the sadata_upcall_alloc()
> routine to before the while loop to avoid this. Thanks for spotting
> this; were you seeing the assertion fire, or just noticing it by
> inspection?
>         - Nathan