Michael Weber wrote:
> It seems, today's GHC made the problem disappear (or, at least, it
> disappeared between 1999/12/06 and 2000/01/09), my test case now 
> works as expected...
> 
> Sven, what about yours? [...]

*Sigh* A similar problem just occurred again! Given the following
code snippet from the FFI proposal:

-----------------------------------------------------
outParamWith :: (a -> Int) -> (Addr -> IO a) -> (Addr -> IO b) -> IO (b,a)
outParamWith sizeOf_ unmarshal_ act = do
   buf <- malloc (sizeOf_ undefined)
   retVal <- act buf
   val <- unmarshal_ buf
   free buf   -- ************** everything works if we comment out this free
   return (retVal, val)
-----------------------------------------------------

It seems as if the unmarshaling (`unmarshal_ buf') is done at the
moment the value of `val' is needed, which depends on the caller of
outParamWith. But at this moment `free buf' has already happend and
Electric Fence correctly complains.

Further investigation shows that this happens when `unmarshal_' is
bound to something like

    fixIO (\val -> <real unmarshaling via readCharOffAddr is done here>)

Hmmm, is this not as strict as I thought?  %-(  Perhaps I should
try `seq' on the returned value...

Confused as usual,
   Sven
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne

Reply via email to