Re: nlffi memory problems on power ppc
Matthias Blume <[email protected]> Tue, 10 Apr 2007 23:49:48 -0500
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
Hi Brian, I tried to experiment a bit with this code, and it is quite frustrating... :-( Indeed, I can reproduce your problem on my G5 using the code you posted. However, adding a bit of instrumentation seems to make the problem go away. In particular, I added a routine for printing the contents of a C array. Putting an invocation of this routine any place where it makes sense makes the problem completely vanish. In other words, this looks more and more like a "Heisenbug". Right now I don't have a good guess at what's causing this. I'll keep looking. Matthias On Mar 8, 2007, at 12:10 AM, brian wrote: > OK. I have a reasonably coherent example and a specific set of > failure conditions, so perhaps someone can tell me what's wrong. > > I should preface this with some info: > > Mac Power PC G5 > Standard ML of New Jersey v110.60 [built: Thu Nov 9 15:44:30 2006] > > Here's the test code: > > fun memtest() = > let fun set(p, i, x) = C.Set.double (C.Ptr.|*| (C.Ptr.|+| (p, > i)), x) > fun fromArray(values) = > let val n = Array.length(values) > val m = C.alloc C.T.double (Word.fromInt n) > val _ = Array.appi (fn (i, x) => set(m, i, x)) values > in > (* return a read-write version of the pointer *) > C.Ptr.rw m > end > val a1 = Array.fromList([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) > val a2 = Array.fromList([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0]) > val b1 = fromArray(a1) > (* val b2 = fromArray(a2) *) > in > C.free b1; > (* C.free b2; *) > () > end > > The test code as is WORKS. > If the "val b2 = ..." line is uncommented, then the test code gives > me a bus error. > If the "C.free b2" line is uncommented, then the code gives me a > segmentation fault. > > Thanks > > Brian > > > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Smlnj-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/smlnj-list > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV