DragonFly kernel List (threaded) for 2007-02
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: missing error check in lwkt_alloc_thread
:hey,
:
:I just ran (via a programming mistake on my side) into a mall bug in lwkt=
:_alloc_thread:
:
: if (stack =3D=3D NULL) {
:#ifdef _KERNEL
: stack =3D (void *)kmem_alloc(&kernel_map, stksize);
:#else
: stack =3D libcaps_alloc_stack(stksize);
:#endif
: flags |=3D TDF_ALLOCATED_STACK;
: }
:
:kmem_alloc() however can return NULL if there is no free memory. Arguabl=
:y, if there is no free memory to satisfy a thread stack, you're hosed any=
:ways, but nevertheless.
:
:I'm not sure how to fix this. Maybe something like this will be sufficie=
:nt?
:
:while (stack =3D=3D NULL) {
: stack =3D (void *)kmem_alloc(&kernel_map, stksize);
: if (stack =3D=3D NULL)
: tsleep(&kernel_map, 0, "stckalc", hz);
:}
:
:I know that there is nobody waking us up in this case, but one second sho=
:uld help the situation. Or we add the possibility of an error return to =
:lwkt_alloc_thread().
:
:comments?
:
:cheers
: simon
I think kmem_alloc() should probably be passed allocation flags just
like kmalloc() is, and panic if it would otherwise return NULL and
M_NULLOK wasn't passed to it.
-Matt
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]