From: Archie Cobbs (archie@whistle.com)
Date: Thu Feb 04 1999 - 13:23:39 EST
Godmar Back writes:
> > A fellow here at work said he seems to have seen the message
> > "malloc(): recursive call" output while running the latest
> > version of kaffe.
>
> Actually, I was too quick with my answer here.
> The real answer is that it's a bug for us to call malloc(), but
> that we cannot rely on supporting libraries to not call malloc().
>
> Since Kaffe is fully preemptive, thread switches can occur inside
> a malloc, and another thread can then reenter the malloc.
>
> The only thing we can do is to disable interrupts while we call
> into functions in foreign libraries that may call malloc().
> This includes libltdl, it also includes printf/stdio, it includes
> a lot of libraries.
Godmar,
I don't know the specifics of when & how this occurred, but
by "recent" I think that means in the past couple of days.
One strategy would be this... tell me how feasible you think
this would be.
We set a global flag bit somewhere anytime we enter one of
these "unsafe" library routines, such as malloc(), printf(),
etc. etc. We also keep an "interrupted" flag bit. When we
return from an unsafe routine, we check if the "interrupted"
flag bit has been set. If so, then we initiate a context
switch.
When we get a signal, we check if the global "unsafe" flag
bit is set. If not, then we immediatley initiate a context
switch. Otherwise, we only set the "interrupted" flag bit
and immediately return.
This is similar to the way that the FreeBSD kernel handles
splnet(), etc.
-Archie
___________________________________________________________________________
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:57 EDT