On Mon, Aug 22, 2005, [EMAIL PROTECTED] said:

> ----------------------------------------------------------------------
>  mavetju - 22-Aug-05 13:15 CEST 
> ----------------------------------------------------------------------
> the recursive malloc is because of calling the trace() in the signal
> handler of alarm(10) in your patch.
> 
> See the man page of malloc(3):
>      recursive call  A process has attempted to call an allocation
> function
>      recursively.  This is not permitted.  In particular, signal handlers
>      should not attempt to allocate memory.
> 
> sprintf() and friends call malloc().

I'm not sure why sprintf would call malloc... but looking at the glibc
code, it gets called quite a lot! Looks like they're fully preparing the
strings before any output happens, rather than output-on-the-fly.

I wonder if we should have a function like trace_static() that either
doesn't use a formatstring, or for which we write our own printf-style
format code. Using a static buffer and/or byte-at-a-time output, we can
avoid malloc.

Aaron

Reply via email to