java-cef
java-cef copied to clipboard
Crash when creating new subprocess
Describe the bug When a java-application with embedded jcef tries to create a subprocess then it sometimes crashes (with SIGABRT). This crash is observed only in OSX Sonoma with x64 architecture. Stacktrace (part):
36 libjvm.dylib 0x107a686e0 JVM_handle_bsd_signal + 304
37 libsystem_platform.dylib 0x7ff80ebe137d _sigtramp + 29
38 ??? 0x0 ???
39 libobjc.A.dylib 0x7ff80e7f4b34 object_dispose + 19
40 Chromium Embedded Framework 0x20b835c92 ChromeAppModeStart_v7 + 31054146
41 libxpc.dylib 0x7ff80e8c7a3f -[OS_xpc_object dealloc] + 47
42 libxpc.dylib 0x7ff80e8e431c xpc_atfork_child + 125
43 libSystem.B.dylib 0x7ff81ba5cc72 libSystem_atfork_child + 63
44 libsystem_c.dylib 0x7ff80ea78025 fork + 84
45 libpty.dylib 0x1a60d5345 exec_pty + 181
46 libjnidispatch.jnilib 0x18cc4811a 0x18cc39000 + 61722
To Reproduce Steps to reproduce the behavior:
- Checkout latest jcef master. Open tests.simple.MainFrame.java and replace method main with next code:
public static void main(String[] args) {
if (!CefApp.startup(args))
return;
new MainFrame("http://www.google.com", true, false);
Thread.sleep(5000);
Runnable testFork = () -> {
int count = 10000;
for (int c = 0; c < count; c++) {
ProcessBuilder pb = new ProcessBuilder("echo");
pb.command().add(String.format("Hello %d", c));
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
try {
Process p = pb.start();
int res = p.waitFor();
if (res != 0)
System.err.printf("test subprocess returns %d\n", res);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
Thread t1 = new Thread(testFork);
Thread t2 = new Thread(testFork);
t1.start();
t2.start();
}
- Compile and run java on OSX Sonoma x64 with next arguments: java -Djdk.lang.Process.launchMechanism=fork -classpath COMPILED_PATH tests.simple.MainFrame
- See crash.
NOTE: if some 'modular' problems observed then next VM-options will be usefull: --add-exports java.desktop/sun.awt=ALL-UNNAMED,jcef --add-exports java.desktop/java.awt.peer=ALL-UNNAMED,jcef --add-exports java.desktop/sun.lwawt.macosx=ALL-UNNAMED,jcef --add-exports java.desktop/sun.lwawt=ALL-UNNAMED,jcef
Expected behavior Expected: test will not fail. Observed: crash (at some iteration).
Versions (please complete the following information):
- OS: MacOS 14.4, x64
- CEF Version: 122.1.9
Please report JCEF issues at https://github.com/chromiumembedded/java-cef/issues
For me this happens after having my computer up for about 1-2 weeks. (It has been annoyingly happening for several YEARS, across 3 different computers and different versions of MacOS X.. from 10.11, 10.15, 11, and 12).
When the crashes start I also see the following other oddities on my computer.
- file open/save dialogs in ANY application take ~ 30 seconds to open
- any chrome-based or webkit-based browser fails to start (no safari, no google chrome, nor any app using CEF, slack, jetbrains IDEs, nothing that kicks in and uses the CEF)
- no camera access works (or takes ~ 30second to a minute to work)
- sharing screen within firefox is slow as well (takes ~ 15-20 seconds to start streaming in a google meeting).
the ONLY fix I have had it so completely shutdown and restart my computer.
Stack trace from Jetbrains' IDE (Phpstorm currently)
Thread 0 Crashed:: main Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x7ff8055a1fce __pthread_kill + 10
1 libsystem_pthread.dylib 0x7ff8055d81ff pthread_kill + 263
2 libsystem_c.dylib 0x7ff805523d14 abort + 123
3 libjvm.dylib 0x1063e9699 os::die() + 9
4 libjvm.dylib 0x106676bac VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long) + 2332
5 libjvm.dylib 0x106676284 VMError::report_and_die(Thread*, unsigned int, unsigned char*, void*, void*, char const*, ...) + 132
6 libjvm.dylib 0x106676f21 VMError::report_and_die(Thread*, unsigned int, unsigned char*, void*, void*) + 33
7 libjvm.dylib 0x106505441 JVM_handle_bsd_signal + 369
8 libsystem_platform.dylib 0x7ff8055eddfd _sigtramp + 29
9 phpstorm 0x104566db6 _$LT$std..io..stdio..StdoutLock$u20$as$u20$std..io..Write$GT$::write_all::h2c413a596aad993f + 326
10 libsystem_c.dylib 0x7ff805523d14 abort + 123
11 libjvm.dylib 0x1063e9681 os::abort(bool, void*, void const*) + 49
12 libjvm.dylib 0x106676be3 VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long) + 2387
13 libjvm.dylib 0x106676284 VMError::report_and_die(Thread*, unsigned int, unsigned char*, void*, void*, char const*, ...) + 132
14 libjvm.dylib 0x106676f21 VMError::report_and_die(Thread*, unsigned int, unsigned char*, void*, void*) + 33
15 libjvm.dylib 0x106505441 JVM_handle_bsd_signal + 369
16 libsystem_platform.dylib 0x7ff8055eddfd _sigtramp + 29
17 ??? 0x0 ???
18 Chromium Embedded Framework 0x1dbaea0f9 ChromeAppModeStart_v7 + 7229049
19 Chromium Embedded Framework 0x1da70e1fb cef_time_from_basetime + 46113115
20 Chromium Embedded Framework 0x1db2947d0 cef_time_from_basetime + 58197808
21 Chromium Embedded Framework 0x1db2945a9 cef_time_from_basetime + 58197257
22 Chromium Embedded Framework 0x1d7a70e9d cef_zip_reader_create + 426365
23 Chromium Embedded Framework 0x1d7a70b3a cef_zip_reader_create + 425498
24 Chromium Embedded Framework 0x1d7a455fb cef_zip_reader_create + 248027
25 Chromium Embedded Framework 0x1d7a452f9 cef_zip_reader_create + 247257
26 Chromium Embedded Framework 0x1d79b2aa5 cef_initialize + 245
27 libjcef.dylib 0x1bfeff3bf CefInitialize(CefMainArgs const&, CefStructBase<CefSettingsTraits> const&, scoped_refptr<CefApp>, void*) + 159
28 libjcef.dylib 0x1bfebf530 +[CefHandler initialize:] + 112
29 Foundation 0x7ff80651d337 __NSThreadPerformPerform + 179
30 CoreFoundation 0x7ff80569f0ab __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
31 CoreFoundation 0x7ff80569f013 __CFRunLoopDoSource0 + 180
32 CoreFoundation 0x7ff80569ed8d __CFRunLoopDoSources0 + 242
33 CoreFoundation 0x7ff80569d7a8 __CFRunLoopRun + 892
34 CoreFoundation 0x7ff80569cd6c CFRunLoopRunSpecific + 562
35 HIToolbox 0x7ff80e34f5e6 RunCurrentEventLoopInMode + 292
36 HIToolbox 0x7ff80e34f34a ReceiveNextEventCommon + 594
37 HIToolbox 0x7ff80e34f0e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
38 AppKit 0x7ff8080dbaa9 _DPSNextEvent + 927
39 AppKit 0x7ff8080da166 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
40 libosxapp.dylib 0x168ab225a -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
41 AppKit 0x7ff8080cc818 -[NSApplication run] + 586
42 libosxapp.dylib 0x168ab2025 +[NSApplicationAWT runAWTLoopWithApp:] + 165
43 libawt_lwawt.dylib 0x1695f5340 +[AWTStarter starter:headless:] + 496
44 libosxapp.dylib 0x168ab401f +[ThreadUtilities invokeBlockCopy:] + 15
45 Foundation 0x7ff80651d337 __NSThreadPerformPerform + 179
46 CoreFoundation 0x7ff80569f0ab __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
47 CoreFoundation 0x7ff80569f013 __CFRunLoopDoSource0 + 180
48 CoreFoundation 0x7ff80569ed8d __CFRunLoopDoSources0 + 242
49 CoreFoundation 0x7ff80569d7a8 __CFRunLoopRun + 892
50 CoreFoundation 0x7ff80569cd6c CFRunLoopRunSpecific + 562
51 phpstorm 0x10458b9fe xplat_launcher::main_lib::he5f939ad598c1b7c + 12217
52 phpstorm 0x104522d26 std::sys_common::backtrace::__rust_begin_short_backtrace::ha26cc71abcdaea83 + 6
53 phpstorm 0x10452301a main + 730