segfault-causing examples

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 main = do print "hello" print (True) print "bye" compiling with my darcs-nhc98 on my computer and running, I get: "hello" Segmentation fault (core dumped) Before trying that, I noticed that Integers had some problems... module Main(main) where main = do print "hello" if 2 > (1::Int) then print "SmartInt" else print "StupidInt" if 2 > (1::Integer) then print "SmartIntegerA" else print "StupidIntegerA" if 1 < (2::Integer) then print "SmartIntegerB" else print "StupidIntegerB" print (1::Int) print (1::Integer) print "bye" My results, plus comments verified by other experiments: "hello" "SmartInt" --Ints are fine "StupidIntegerA" --Integers are "SmartIntegerB" --not working right 1 --Ints are still fine Segmentation fault (core dumped) --Instance Show Integer crashes the program show (1::Integer) `seq` print "integ" --prints "integ" (shallow seq) foldr seq () (show (1::Integer)) `seq` print "integ" --crashes (deep seq) I suppose maybe I compiled nhc wrong, since I manually modified an "==" to "=" in one file, and restarted its compilation several times, though I can't see how those could cause these problems... Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6Jk6HgcxvIWYTTURApy5AJ971v1rRcy6fqnBrTheaQarakIPNgCfXZmg sRq1AhmrIxPIW9bY58bbbUw= =FLqA -----END PGP SIGNATURE-----

Isaac Dupree
main = do if 1 < (2::Integer) then print "SmartIntegerB" else print "StupidIntegerB"
"SmartIntegerB" --not working right
That looks like the correct result to me.
Segmentation fault (core dumped) --Instance Show Integer crashes the program
Interesting.
I suppose maybe I compiled nhc wrong, since I manually modified an "==" to "=" in one file, and restarted its compilation several times, though I can't see how those could cause these problems...
The "==" to "=" change was fine, and there is now a patch in the repo for that anyway. You say that your gcc gives random crashes. My best guess is flaky hardware - bad memory. Maybe there was some random corruption in gcc whilst building something in the runtime system. I would try rm targets/powerpc-Darwin8/obj/runtime rm targets/powerpc-Darwin8/runtime make runtime and see if you get the same behaviour. Regards, Malcolm

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Malcolm Wallace wrote:
You say that your gcc gives random crashes. My best guess is flaky hardware - bad memory.
Yes, I know that's the usual theory, I've run memory tests and haven't detected any. Maybe gcc is buggy and corrupts its stack unpredictably. Although that could just as well produce incorrect results sometimes, I suppose. As a reference point, my machine is a Yhc buildbot and that seems to work fine when gcc (called by ghc) doesn't outright crash. Hmm... compiling with -O3 with "gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)" things (including bits of GMP) maybe isn't quite safe? Apparently C compilers are unreliable enough these days that "It has now come to the point where a compiler should be assumed to miscompile GMP." http://gmplib.org/ and "It might seem that GMP is unusually unlucky with compilers, that it triggers more bugs than other packages. I believe that is an illusion. What really is happening, is that GMP has a test suite that will find almost every miscompilation in the library." http://gmplib.org/list-archives/gmp-bugs/2007-February/000698.html
Maybe there was some random corruption in gcc whilst building something in the runtime system. I would try rm targets/powerpc-Darwin8/obj/runtime rm targets/powerpc-Darwin8/runtime make runtime and see if you get the same behaviour.
rm -r targets/ppc-Linux/obj/runtime/ rm targets/ppc-Linux/runtime make runtime make install This didn't help. BTW my --prefix=/home/isaac/install/nhc98 (and I haven't put that/bin in my PATH) Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF6LO5HgcxvIWYTTURAnnvAKCB1Oq3irRKx8ZyTEibfpmoqWSYmwCgvIqK P1WL7QS06iBHkdCMp5s72Fk= =5wWy -----END PGP SIGNATURE-----

Isaac Dupree
Maybe there was some random corruption in gcc whilst building something in the runtime system.
rm -r targets/ppc-Linux/obj/runtime/ rm targets/ppc-Linux/runtime make runtime make install
This didn't help.
I'm afraid I'm out of ideas then. Is your powerpc a 64-bit G5, or a 32-bit G3/G4? If a 64-bit machine, does your version of gcc also generate 64-bit code by default, or it is set to 32-bit mode? Regards, Malcolm

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I tried completely rebuilding from a clean checkout, first changing -O3 to -O0 in Makefile.inc. It didn't help. Malcolm Wallace wrote:
I'm afraid I'm out of ideas then. Is your powerpc a 64-bit G5, or a 32-bit G3/G4? If a 64-bit machine, does your version of gcc also generate 64-bit code by default, or it is set to 32-bit mode?
It's a 32-bit G3. Isaac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF710BHgcxvIWYTTURAosoAJ9x4NpYEPBYkdXpdGKdVTENcHdD9wCg2C+z KiS+j1rMCX2nRLCooJRPPTs= =ioXH -----END PGP SIGNATURE-----
participants (2)
-
Isaac Dupree
-
Malcolm Wallace