[Haskell-cafe] Getting a segmentation fault when starting/stopping the RTS, from C, several times.

Captain Freako capn.freako at gmail.com
Wed Jul 11 04:55:58 CEST 2012

Hi experts,

Should I expect the following C code to run to completion, or am I trying
to do something that was never intended?


C code:

  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include "HsFFI.h"
  5 int main()
  6 {
  7     int argc = 1, i;
  8     char* argv[] = {"ghcDll", NULL}; // argv must end with NULL
  9     char** args = argv;
 11     for(i=0; i<10; i++) {
 12         fprintf(stderr, "Starting up the RTS...\n");
 13         hs_init(&argc, &args);
 14         printf("Shutting down the RTS...\n");
 15         hs_exit();
 16     }
 17 }

This is what I get, when I compile and run it:

dbanas at dbanas-eeepc:~/prj/haskell/amitool$ make test_rts
rm -f test_rts
ghc -o test_rts -lHSrts -lm -lffi -lrt test_rts.o
dbanas at dbanas-eeepc:~/prj/haskell/amitool$ ./test_rts
Starting up the RTS...
Shutting down the RTS...
Starting up the RTS...
Shutting down the RTS...
Segmentation fault
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120710/166e83c8/attachment.htm>

More information about the Haskell-Cafe mailing list