chromiumembedded / java-cef

Java Chromium Embedded Framework (JCEF). A simple framework for embedding Chromium-based browsers in other applications using the Java programming language.
https://bitbucket.org/chromiumembedded/java-cef
Other
602 stars 135 forks source link

Crash when creating new subprocess #471

Open artemm-bochkarev opened 2 months ago

artemm-bochkarev commented 2 months ago

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:

  1. 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();
    }
  1. Compile and run java on OSX Sonoma x64 with next arguments: java -Djdk.lang.Process.launchMechanism=fork -classpath COMPILED_PATH tests.simple.MainFrame
  2. 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):

magreenblatt commented 2 months ago

Please report JCEF issues at https://github.com/chromiumembedded/java-cef/issues