Re: Java GC causes a crash a library Nim runtime on linux

2019-11-02 Thread alexsad
Araq, awesome, that solves it!

thanks a lot!


Re: Java GC causes a crash a library Nim runtime on linux

2019-11-01 Thread Araq
Try to compile with `-d:noSignalHandler`, Java's GC uses signal handlers to 
intercept threads for collecting.


Java GC causes a crash a library Nim runtime on linux

2019-11-01 Thread alexsad
Hi All!

this week i tried to implement JNI library written on Nim(v.1.0.2) using 
templates from 
[https://gist.github.com/jangko/48ba0b76716d0631560e5f2ff470256d](https://gist.github.com/jangko/48ba0b76716d0631560e5f2ff470256d)
 and also jnim 
[https://github.com/yglukhov/jnim](https://github.com/yglukhov/jnim) but 
unfortunately on linux OS got error at runtime:

> No stack traceback available
> 
> SIGSEGV: Illegal storage access. (Attempt to read from nil?)

i recognized that it happens when Java starts GC collect.

Steps to reproduce:

  * empty.nim (exactly absolute empty file) compile it with nim c --app:lib 
empty.nim
  * Sample.java compile with javac Sample.java (see code bellow)




public class Sample
{
  
  public static void main(String[] args)
  {
System.load("/absolute/path/to/libempty.so");
//System.load("absolute\\path\\to\\empty.dll");

for(int j=0; j<5; j++){
System.out.println("Java GC starts...");
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.out.println("Java GC finished...");
}
  }
}


Run

But on windows OS it works properly.

Please any suggestion on it, perhaps additional switches for Nim compiler?

Thanks.