[M3devel] malloc/free from Modula-3?
Jay K
jay.krell at cornell.edu
Tue Apr 19 01:20:57 CEST 2011
And "yes" you need to disable switching around free, the same as malloc. And calloc. And realloc.
The disable switching *might* be at a lower level than you realize, so *might* not be missing.
That is, it might be in our C wrappers. I can check later.
- Jay
> From: hosking at cs.purdue.edu
> Date: Mon, 18 Apr 2011 12:30:45 -0400
> To: mika at async.caltech.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] malloc/free from Modula-3?
>
> 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.)
> >
> > Mika
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20110418/bf9467bb/attachment-0002.html>
More information about the M3devel
mailing list