D.gnu - Bug in calling C function on Windows?
- Bradley Smith (14/14) Jan 08 2007 I'm experimenting with using D for Java Native Interface (JNI)
- Juan Jose Comellas (5/24) Jan 09 2007 This mail is not related specifically to your problem. I just wanted to ...
- Bradley Smith (5/33) Jan 09 2007 Thanks. I was unaware of that. It appears that the JVM signal use can be...
- Juan Jose Comellas (4/40) Jan 09 2007 Not that I'm aware of. DMD/Phobos hardcode the SIGUSR1 and SIGUSR2 signa...
- Sean Kelly (12/55) Jan 09 2007 This is something that has bothered me for a while about the garbage
I'm experimenting with using D for Java Native Interface (JNI) programming. I may have encountered a bug with GDC calling a C function in the JavaVM invocation API. The following is the relevant code. JNI_CreateJavaVM(&jvm, cast(void**)&env, &vm_args); version (gdcBugWorkaround) { // Any statement can go here (even "int x = 0;") assert (jvm !is null, "JNI_CreateJavaVM failed"); } For some reason, the program will crash unless some kinds of statements follow the call to JNI_CreateJavaVM. Is this a bug? The full code and a build.bat script are in the attached zip. I'm using gdc --version: "gdc (GCC) 3.4.5 (mingw special) (gdc 0.21, using dmd 1.00)" Thanks, Bradley
Jan 08 2007
This mail is not related specifically to your problem. I just wanted to warn you that both the JVM and DMD/Phobos use the same Unix signals for garbage collection (SIGUSR1 and SIGUSR2) on Linux. All hell will break loose if you don't remap the signals the JVM uses. Bradley Smith wrote:I'm experimenting with using D for Java Native Interface (JNI) programming. I may have encountered a bug with GDC calling a C function in the JavaVM invocation API. The following is the relevant code. JNI_CreateJavaVM(&jvm, cast(void**)&env, &vm_args); version (gdcBugWorkaround) { // Any statement can go here (even "int x = 0;") assert (jvm !is null, "JNI_CreateJavaVM failed"); } For some reason, the program will crash unless some kinds of statements follow the call to JNI_CreateJavaVM. Is this a bug? The full code and a build.bat script are in the attached zip. I'm using gdc --version: "gdc (GCC) 3.4.5 (mingw special) (gdc 0.21, using dmd 1.00)" Thanks, Bradley
Jan 09 2007
Thanks. I was unaware of that. It appears that the JVM signal use can be removed with the -Xrs option. Is it possible to do the same in DMD/Phobos? Thanks, Bradley Juan Jose Comellas wrote:This mail is not related specifically to your problem. I just wanted to warn you that both the JVM and DMD/Phobos use the same Unix signals for garbage collection (SIGUSR1 and SIGUSR2) on Linux. All hell will break loose if you don't remap the signals the JVM uses. Bradley Smith wrote:I'm experimenting with using D for Java Native Interface (JNI) programming. I may have encountered a bug with GDC calling a C function in the JavaVM invocation API. The following is the relevant code. JNI_CreateJavaVM(&jvm, cast(void**)&env, &vm_args); version (gdcBugWorkaround) { // Any statement can go here (even "int x = 0;") assert (jvm !is null, "JNI_CreateJavaVM failed"); } For some reason, the program will crash unless some kinds of statements follow the call to JNI_CreateJavaVM. Is this a bug? The full code and a build.bat script are in the attached zip. I'm using gdc --version: "gdc (GCC) 3.4.5 (mingw special) (gdc 0.21, using dmd 1.00)" Thanks, Bradley
Jan 09 2007
Not that I'm aware of. DMD/Phobos hardcode the SIGUSR1 and SIGUSR2 signals to start and stop the garbage collection cycle, as all threads need to be paused while the garbage collector is running. Bradley Smith wrote:Thanks. I was unaware of that. It appears that the JVM signal use can be removed with the -Xrs option. Is it possible to do the same in DMD/Phobos? Thanks, Bradley Juan Jose Comellas wrote:This mail is not related specifically to your problem. I just wanted to warn you that both the JVM and DMD/Phobos use the same Unix signals for garbage collection (SIGUSR1 and SIGUSR2) on Linux. All hell will break loose if you don't remap the signals the JVM uses. Bradley Smith wrote:I'm experimenting with using D for Java Native Interface (JNI) programming. I may have encountered a bug with GDC calling a C function in the JavaVM invocation API. The following is the relevant code. JNI_CreateJavaVM(&jvm, cast(void**)&env, &vm_args); version (gdcBugWorkaround) { // Any statement can go here (even "int x = 0;") assert (jvm !is null, "JNI_CreateJavaVM failed"); } For some reason, the program will crash unless some kinds of statements follow the call to JNI_CreateJavaVM. Is this a bug? The full code and a build.bat script are in the attached zip. I'm using gdc --version: "gdc (GCC) 3.4.5 (mingw special) (gdc 0.21, using dmd 1.00)" Thanks, Bradley
Jan 09 2007
This is something that has bothered me for a while about the garbage collection mechanism in D, but I'm not aware of a way around it. An interrupt must be sent between threads to suspend and resume processing, and SIGUSR1/SIGUSR2 are the only reasonable means of doing so that I'm aware of. Worse yet, only one signal handler can be registered for each signal at a time (as far as I'm aware), so SIGUSR1 and SIGUSR2 are effectively reserved for use by the GC in D. In Windows, since signals are essentially unsupported, some debug routines are used instead to externally suspend and resume running threads. This actually works a bit better than the Unix solution because it doesn't cancel kernel routines that may be processing in the thread to be suspended. Juan Jose Comellas wrote:Not that I'm aware of. DMD/Phobos hardcode the SIGUSR1 and SIGUSR2 signals to start and stop the garbage collection cycle, as all threads need to be paused while the garbage collector is running. Bradley Smith wrote:Thanks. I was unaware of that. It appears that the JVM signal use can be removed with the -Xrs option. Is it possible to do the same in DMD/Phobos? Thanks, Bradley Juan Jose Comellas wrote:This mail is not related specifically to your problem. I just wanted to warn you that both the JVM and DMD/Phobos use the same Unix signals for garbage collection (SIGUSR1 and SIGUSR2) on Linux. All hell will break loose if you don't remap the signals the JVM uses. Bradley Smith wrote:I'm experimenting with using D for Java Native Interface (JNI) programming. I may have encountered a bug with GDC calling a C function in the JavaVM invocation API. The following is the relevant code. JNI_CreateJavaVM(&jvm, cast(void**)&env, &vm_args); version (gdcBugWorkaround) { // Any statement can go here (even "int x = 0;") assert (jvm !is null, "JNI_CreateJavaVM failed"); } For some reason, the program will crash unless some kinds of statements follow the call to JNI_CreateJavaVM. Is this a bug? The full code and a build.bat script are in the attached zip. I'm using gdc --version: "gdc (GCC) 3.4.5 (mingw special) (gdc 0.21, using dmd 1.00)" Thanks, Bradley
Jan 09 2007