Bug 547109 - [GTK] JVM crash when multiple processes were started and native libraries are missing
Summary: [GTK] JVM crash when multiple processes were started and native libraries are...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.12   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.12 M3   Edit
Assignee: Alexandr Miloslavskiy CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-05-09 04:14 EDT by Alexandr Miloslavskiy CLA
Modified: 2019-06-18 14:14 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr Miloslavskiy CLA 2019-05-09 04:14:08 EDT
The problem is related to how SWT extracts libraries when they are missing.

If multiple processes are started quickly when libraries are missing, the following happens:
1) Process A notices that library is missing and starts extracting it
2) Process B finds incomplete library and loads it
3) JVM crashes with SIGBUS - BUS_ADRERR in NativeLibrary.load()

I'll prepare a patch for this: use a temp file and rename it when fully extracted.
Comment 1 Eclipse Genie CLA 2019-05-09 10:40:59 EDT
New Gerrit change created: https://git.eclipse.org/r/141885
Comment 2 Alexandr Miloslavskiy CLA 2019-05-13 05:47:28 EDT
Before the patch, following problems happened:

-----------------------------------
On Linux - JVM will crash like this
-----------------------------------
siginfo: si_signo: 7 (SIGBUS), si_code: 2 (BUS_ADRERR), si_addr: 0x00007ff852a28428

Stack: [0x00007ff8dae89000,0x00007ff8db08a000],  sp=0x00007ff8db085bd8,  free space=2034k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ld-linux-x86-64.so.2+0x1dc94]
C  [ld-linux-x86-64.so.2+0x8c27]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.ClassLoader$NativeLibrary.load(Ljava/lang/String;Z)V+0
j  java.lang.ClassLoader.loadLibrary0(Ljava/lang/Class;Ljava/io/File;)Z+328
j  java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)V+48
j  java.lang.Runtime.load0(Ljava/lang/Class;Ljava/lang/String;)V+57
j  java.lang.System.load(Ljava/lang/String;)V+7
j  org.eclipse.swt.internal.Library.load(Ljava/lang/String;Ljava/lang/StringBuilder;)Z+12
j  org.eclipse.swt.internal.Library.loadLibrary(Ljava/lang/String;Z)V+230
j  org.eclipse.swt.internal.Library.loadLibrary(Ljava/lang/String;)V+2
j  org.eclipse.swt.internal.cairo.Cairo.<clinit>()V+2
...

-----------------------------------
On Windows - SWT exception
-----------------------------------
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
	<snip>\swt-win32-4926r17.dll: The process cannot access the file because it is being used by another process
	Can't load library: <snip>\swt-win32.dll
	no swt-win32-4926r17 in java.library.path: [<snip>]
	no swt-win32 in java.library.path: [<snip>]

-----------------------------------
On macOS - SWT exception
-----------------------------------
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
	<snip>/libswt-pi-cocoa-4926r17.jnilib: dlopen(<snip>/libswt-pi-cocoa-4926r17.jnilib, 1): no suitable image found.  Did find:
	<snip>/libswt-pi-cocoa-4926r17.jnilib: truncated mach-o error: segment __TEXT extends to 155648 which is past end of file 86016
	<snip>/libswt-pi-cocoa-4926r17.jnilib: truncated mach-o error: segment __TEXT extends to 155648 which is past end of file 86016
	Can't load library: <snip>/libswt-pi-cocoa.jnilib
	no swt-pi-cocoa-4926r17 in java.library.path: [<snip>]
	no swt-pi-cocoa in java.library.path: [<snip>]
Comment 4 Eclipse Genie CLA 2019-05-21 00:22:04 EDT
New Gerrit change created: https://git.eclipse.org/r/142470
Comment 5 Eclipse Genie CLA 2019-05-21 00:43:19 EDT
New Gerrit change created: https://git.eclipse.org/r/142471
Comment 8 Eric Williams CLA 2019-06-18 14:13:21 EDT
In master now.
Comment 9 Eric Williams CLA 2019-06-18 14:14:02 EDT
Verified in I20190612-0115.