I'm trying to create a small C++ program which embed R, but I'm having
problems when I try to do it on Windows 64 bits. I have created a
minimal reproducible example which is just the
src/gnuwin32/front-ends/rtest.c file with the R_ReplDLLdo1() loop, the
only difference is that I set the interactive mode to TRUE. Here is
the cpp file: https://gist.github.com/anonymous/08b42e83c949e250f60b068d58a3ec51
When compiled in 32 bits, everything works: I enter R commands and no
crash. When compiled in 64 bits (mingw64 and R x64 libs, and executed
with R x64 in the PATH), everything works except when there is an
error in R with a command entered by the user. Typically, entering "a"
shows "Error: object 'a' not found" and then the program immediately
crashes. Typing a stop() also trigger a crash.
Code returned by the program is 0xC0000028, which is STATUS_BAD_STACK
with the description: "An invalid or unaligned stack was encountered
during an unwind operation". I'm not really good at C++ or
makefile/compiler stuff, but I can't get it to work. I'm guessing this
as to do with some longjumps to return to the prompt when there is an
error but I don't know how to fix it.