2

So I'm attempting to write a Haskell library using FFI bindings. I seem to have messed up somewhere and I'm getting seg faults:

$ cat test.input| ./dist/build/test-fftsStub/test-fftsStub
Cases: 1  Tried: 0  Errors: 0  Failures: 0got here
now here
ran init
ran execute
[1]    12406 done                              cat test.input | 
       12407 segmentation fault (core dumped)  ./dist/build/test-fftsStub/test-fftsStub
$

It says that the core has been dumped...but I can't find it anywhere on disk. There is no core file:

$ ls -1 | grep core
$

Now I tried to raise the ulimit for my terminal which works for C core dumps:

$ulimit -c unlimited    
$ cat test.input| ./dist/build/test-fftsStub/test-fftsStub 
Cases: 1  Tried: 0  Errors: 0  Failures: 0got here
now here
ran init
ran execute
[1]    12694 done                              cat test.input | 
       12695 segmentation fault (core dumped)  ./dist/build/test-fftsStub/test-fftsStub
$ ls -1 | grep core                                       
cabal-test-run-with-ext-core-flag.out
$ 

Question: Where is the core dumped to / how do I get the core dump?

Successful Core Dump, now what?

Edit: Okay I have the coredump now. Turns out on Ubuntu I had to:

sudo service stop apport

So that it would not toss away my core dump. However, now how do I compare that core dump with the original Haskell code...or even the C equivalent. At this point in time I have resorted to printf debugging in the C library that I am attempting to FFI wrap.

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
  • This question is not specific to Haskell. Linux and Unix core dumps are managed by the operating system, not by the application. – Robin Green Dec 01 '13 at 21:56
  • So, the key question is, which operating system - and if it is not Mac OS X, which distribution? – Robin Green Dec 01 '13 at 21:58
  • I'm running Ubuntu linux @RobinGreen and the reason that I assumed that it was related to Haskell is that running ulimit -c unlimited is usually enough to make the core dumps appear. – Robert Massaioli Dec 01 '13 at 22:28
  • 1
    yes, I thought that ulimit was enough too, but in recent years that does not seem to be the case. [This answer](http://stackoverflow.com/a/18428730/495796) may be useful (read all of it). – Robin Green Dec 01 '13 at 22:32
  • Does your program change the directory? – Ingo Dec 01 '13 at 23:22
  • @Ingo My program does not change the directory. But that seems to be covered by the version of Cabal that I am using. – Robert Massaioli Dec 03 '13 at 04:42
  • I have updated the question now. Does anybody know the answer to that? – Robert Massaioli Dec 03 '13 at 04:42

0 Answers0