Getting a segmentation fault when starting/stopping the RTS, from C, several times.
Hi experts, Should I expect the following C code to run to completion, or am I trying to do something that was never intended? Thanks, -db C code: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include "HsFFI.h" 4 5 int main() 6 { 7 int argc = 1, i; 8 char* argv[] = {"ghcDll", NULL}; // argv must end with NULL 9 char** args = argv; 10 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@dbanas-eeepc:~/prj/haskell/amitool$ make test_rts rm -f test_rts ghc -o test_rts -lHSrts -lm -lffi -lrt test_rts.o dbanas@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
On Tue, Jul 10, 2012 at 10:55 PM, Captain Freako <capn.freako@gmail.com>wrote:
Hi experts,
Should I expect the following C code to run to completion, or am I trying to do something that was never intended?
Quoth the Fine Manual (8.2.1.1. Using your own main()<http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-own-main> ): There can be multiple calls to hs_init(), but each one should be matched by one (and only one) call to hs_exit()[14<http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ftn.id740774> ]. So this should theoretically work. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
On 12-07-10 11:35 PM, Brandon Allbery wrote:
Quoth the Fine Manual (8.2.1.1. Using your own main() <http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-own-main>):
There can be multiple calls to |hs_init()|, but each one should be matched by one (and only one) call to |hs_exit()|^[14 <http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ftn.id740774>] .
So this should theoretically work.
Except that [14] says: the outermost hs_exit() de-initialises, and afterwards, cannot reliably re-initialise in current implementations. So the currently working use-case is just: Prog ::= nop | hs_init(); Prog; hs_exit()
Em 15/07/2012 18:38, "Albert Y. C. Lai" <trebla@vex.net> escreveu:
On 12-07-10 11:35 PM, Brandon Allbery wrote:
Quoth the Fine Manual (8.2.1.1. Using your own main() <
http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-o...
):
There can be multiple calls to |hs_init()|, but each one should be matched by one (and only one) call to |hs_exit()|^[14 <
http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ftn.id7... ]
.
So this should theoretically work.
Except that [14] says: the outermost hs_exit() de-initialises, and afterwards, cannot reliably re-initialise in current implementations.
So the currently working use-case is just: Prog ::= nop | hs_init(); Prog; hs_exit()
Would that be: Prog ::= nop | hs_init(); Prog'; hs_exit(); Prog' ::= nop | hs_init(); Prog'; hs_exit(); | Prog' Prog' Cheers, -- Felipe – enviado do meu Galaxy Tab.
participants (4)
-
Albert Y. C. Lai -
Brandon Allbery -
Captain Freako -
Felipe Almeida Lessa