[M3devel] malloc/free from Modula-3?
mika at async.caltech.edu
Mon Apr 18 18:10:28 CEST 2011
Tony Hosking writes:
>I suspect the problem is re-entrance to the library. Should you be =
>disabling user thread switching somewhere?
I suspect the same. That's why I asked what the "rules" are
for calling malloc and free. I notice that the m3core code has
Scheduler.DisableSwitching around all calls to malloc but not around calls
to free. Why would one be unsafe and the other safe? It is always free
that my program hangs up on by the way. Surrounding all "suspicious" calls
in my code with Scheduler.DisableSwitching doesn't solve the problem, as
far as I can tell.
I am further suspecting that my problem is related to my having linked the
program with -pthread. I am also guessing that this is the same reason
you can't link FreeBSD user threads programs with -pthread: namely that if
you go reentrantly into the pthread malloc library some code assumes
the two invocations are from separate threads and locks up if they are from
the same thread. That's my guess anyhow. But that doesn't explain why
I've never seen any malloc/free problems on FreeBSD without -pthread.
(I don't think I have, anyhow.)
More information about the M3devel