[M3devel] malloc/free from Modula-3?
hosking at cs.purdue.edu
Mon Apr 18 18:30:45 CEST 2011
Yes, I think you should avoid -pthread.
Antony Hosking | Associate Professor | Computer Science | Purdue University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484
On Apr 18, 2011, at 12:10 PM, Mika Nystrom wrote:
> 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