Re: bug?

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Thu Feb 04 1999 - 13:27:41 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.
>

Sometimes I feel I'm sending so much mail to kaffe-core that people
don't have the time to read it anymore.

What you suggest is what Alexandre suggested to, and it is what
we're implementing for several years now. You just have to wrap
to async-signal-unsafe with calls to jthread_spinon(0)/jthread_spinoff(0).
(for now, at least)

        - Godmar


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:57 EDT