I am having difficulty with the latest version of XSB. I am attempting to embed an XSB instance within a Java process. To do this I have written a JNI interface to the portions of the XSB API that I need. When I use a 64-bit JVM on Windows 7, together with a 64-bit build of XSB 3.40 and a 64-bit build of my JNI DLL, this works well. However, when I switch to 32 bits, Windows consistently throws an EXCEPTION_STACK_OVERFLOW (0xc00000fd). Using a debug build, I get the following stack trace:
xsb.dll!_chkstk() Line 99
xsb.dll!tilde_expand_filename(char * filename) Line 191 + 0x15 bytes
xsb.dll!builtin_call(unsigned char number) Line 2153 + 0xd bytes
xsb.dll!emuloop(unsigned char * startaddr) Line 2745 + 0xa bytes
xsb.dll!xsb(int flag, int argc, char * * argv) Line 3148 + 0xc bytes
xsb.dll!xsb_init(int argc, char * * argv) Line 1403 + 0xb bytes
xsb.dll!xsb_init_string(char * cmdline_param) Line 1462 + 0xd bytes
JNIEnv_ * pEnv, _jclass * cls, _jstring * options)
Line 57 + 0x1a bytes
(Here the bottom entry is within the JVM, and the second-to-bottom entry is in my JNI DLL. This calls xsb_init_string(), and you can see the remainder of the trace within the XSB DLL itself.)
This stack overflow happens with both the XSN binary distribution on your web site and a version I built myself according to your XSB manual.
I have packaged up my JNI DLL for you to test with. Here are the steps to build it:
* Make sure JAVA_HOME points to a 32-bit JDK and that XSB_DIR points to your XSB home directory.
* Unzip the attachment and cd to the resulting directory. Run the command "ant" at the command line. This will compile the Java code and generate the JNI header file.
* Open the Visual Studio solution (the provided solution is for VS 2010), and build the "Debug Win32" configuration.
* Back at the command line, run "ant runJniTest". This runs a small test program that simply calls xsb_init_string() via the JNI DLL. After starting, but before calling xsb_init_string(), the Java code prints its process ID and pauses for 20 seconds. This gives you time to attach the Visual Studio debugger to the process to observe the exception.
Please let me know what I am doing wrong.