HumbleUI / Skija

Java bindings for Skia
Apache License 2.0
498 stars 34 forks source link

Starting two Skija-using applications at the same time may segfault #54

Closed dzaima closed 1 year ago

dzaima commented 1 year ago

possibly some race condition on writing/reading /tmp/skija_0.109.1_x64/libskija.so?

Linux Mint 21.1

Current thread (0x00007fbc9402d070):  JavaThread "main" [_thread_in_native, id=10025, stack(0x00007fbc9afeb000,0x00007fbc9b0eb000)]

Stack: [0x00007fbc9afeb000,0x00007fbc9b0eb000],  sp=0x00007fbc9b0e72c8,  free space=1008k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ld-linux-x86-64.so.2+0x2b1fa]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jdk.internal.loader.NativeLibraries.load(Ljdk/internal/loader/NativeLibraries$NativeLibraryImpl;Ljava/lang/String;ZZ)Z+0 java.base@19.0.2
j  jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open()Z+56 java.base@19.0.2
j  jdk.internal.loader.NativeLibraries.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)Ljdk/internal/loader/NativeLibrary;+254 java.base@19.0.2
j  jdk.internal.loader.NativeLibraries.loadLibrary(Ljava/lang/Class;Ljava/io/File;)Ljdk/internal/loader/NativeLibrary;+51 java.base@19.0.2
j  java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/io/File;)Ljdk/internal/loader/NativeLibrary;+31 java.base@19.0.2
j  java.lang.Runtime.load0(Ljava/lang/Class;Ljava/lang/String;)V+61 java.base@19.0.2
j  java.lang.System.load(Ljava/lang/String;)V+7 java.base@19.0.2
j  io.github.humbleui.skija.impl.Library.load()V+176
j  io.github.humbleui.skija.impl.Library.staticLoad()V+19
j  io.github.humbleui.skija.Font.<clinit>()V+0
v  ~StubRoutines::call_stub 0x00007fbc8452ccc6
j  io.github.humbleui.jwm.examples.Example.<clinit>()V+34
v  ~StubRoutines::call_stub 0x00007fbc8452ccc6
tonsky commented 1 year ago

Might be. How often does it happen?

dzaima commented 1 year ago

Maybe some 20% of the time in the controlled scenario of rming that file and launching two JWM example instances (doesn't happen without the rm); but it's more like 100% in the situation I'm encountering it in - booting up my OS & running a script to start all my GUIs.

tonsky commented 1 year ago

I’m happy to accept a PR if you can solve this. Maybe some sort of FS lock is needed?