Basically my code crashes in NucleoProf_init, judging by gdb’s stack-trace, and by the fact that is the only function that I call.
#include <HsFFI.h>
static char *argv[] = {"NucleoProf", "", "", 0};
static int argc = 1;
HsBool NucleoProf_init(void){
// Initialize Haskell runtime
hs_init(&argc, (char***)&argv );
return HS_BOOL_TRUE;
}
I suspect that it is the way I pass the argv argument, or perhaps, the typecast of argv, because the stack-trace contains the following:
#3 0x00007ffff5956282 in setFullProgArgv ()
from /usr/lib/ghc/libHSrts-ghc7.4.1.so
#4 0x00007ffff5956d04 in hs_init_ghc () from /usr/lib/ghc/libHSrts-ghc7.4.1.so
#5 0x00007ffff5b9ed4f in NucleoProf_init ()
Question: Is this the correct way of “synthesizing” a trivial command line?
You can try this:
It’s unclear why you would need to pass the array by address, but I don’t know the API you’re using. Double-check the manual to see if those values can be changed by the function and if you need to process them afterwards.