Re: bug?

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Thu Feb 04 1999 - 03:38:46 EST


>
> A fellow here at work said he seems to have seen the message
> "malloc(): recursive call" output while running the latest
> version of kaffe.
>
> This message always indicates a bug, usually the bug being that
> somebody is calling malloc() from within a signal handler.
>
> Is it possible that we are doing this? Because if we are then that's
> a problem, as you're not guaranteed that malloc() is reentrant
> (and under FreeBSD it's not).
>

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.

Other libraries, such as libz, have options to pass in memory
allocators or preallocate objects (like X11 sometimes does): of course,
we'll use those when provided.

If the call to malloc is through a encompassing function, like
in libX11, it may be sufficient to synchronize on the entry point
to the encompassing functions --- but this assume malloc isn't called
from anywhere else.

What a mess. I think we should fix libltdl first and see where that
gets us.

        - Godmar


Date view Thread view Subject view Author view

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