dmgolubovsky / yhc

Automatically exported from code.google.com/p/yhc
0 stars 0 forks source link

Factorial program dies a thousand deaths: assert, segfault, full heap #78

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A simple factorial program will cause yhi to die in a number of colorful
ways.  Varying the size of the factorial computed and the available heap
changes the type of crash, but in a kind of scattershot pattern.  However,
the results for each pair of values are identical for repeated runs.

My colleague Jeremy Shaw speculates that the use of large Integers,
implemented with the gmp library, may be causing the problem.  Rumors
abound that binding to gmp can be tricky.

Issue #3 could well be a manifestation of the same bug.

Platform: yhc version 0.7.0, running on Debian Linux unstable.

I am attaching the log of a bugreport (ghc) script that samples a grid of
factorial n vs heap size, showing the different failures.  The log contains
the source code of both the factorial program and the bugreport script
itself, so it should be fully reproducible.

Original issue reported on code.google.com by clifford...@gmail.com on 9 Nov 2006 at 5:10

Attachments:

GoogleCodeExporter commented 9 years ago
Excellent, well found :-) 

Yes it does look like the interaction with the GMP library is playing up 
somewhere.
Since the segfaults are all in _primIntegerRem. 

I don't find it especially surprising that it runs out of heap, and I suspect 
the
assert failure is probably a "delayed segfault" (i.e. an incorrect write that 
didn't
happen to segfault).

Thanks for your help, I'll look into it.

Original comment by tomshack...@gmail.com on 9 Nov 2006 at 7:43

GoogleCodeExporter commented 9 years ago

Original comment by ndmitch...@gmail.com on 9 Nov 2006 at 7:53