brettwooldridge / NuProcess

Low-overhead, non-blocking I/O, external Process implementation for Java
Apache License 2.0
712 stars 84 forks source link

Crash on MacOS #86

Closed slandelle closed 6 years ago

slandelle commented 6 years ago

Hi,

I've upgraded to 1.2.0 and got this weird stacktrace:

java.lang.RuntimeException: kevent 0: error 3
kevent 3: error 32

    at com.zaxxer.nuprocess.osx.ProcessKqueue.registerEvents(ProcessKqueue.java:153)
    at com.zaxxer.nuprocess.osx.ProcessKqueue.registerProcess(ProcessKqueue.java:113)
    at com.zaxxer.nuprocess.osx.ProcessKqueue.registerProcess(ProcessKqueue.java:42)
    at com.zaxxer.nuprocess.internal.BasePosixProcess.registerProcess(BasePosixProcess.java:605)
    at com.zaxxer.nuprocess.internal.BasePosixProcess.start(BasePosixProcess.java:189)
    at com.zaxxer.nuprocess.osx.OsxProcessFactory.createProcess(OsxProcessFactory.java:34)
    at com.zaxxer.nuprocess.NuProcessBuilder.start(NuProcessBuilder.java:266)
        ...
> uname -a
Darwin MacBook-Pro-de-slandelle.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Oct  2 22:20:08 PDT 2017; root:xnu-3248.71.4~1/RELEASE_X86_64 x86_64
> java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

I was just trying to perform a mkdir on the local host. I've never seen this exception with previous versions. Any idea?

brettwooldridge commented 6 years ago

@slandelle Thanks, looking into it. A test class would be useful.

slandelle commented 6 years ago

@brettwooldridge Thanks! I was not able to reproduce so far. I'll let you know if I end up finding a way.

brettwooldridge commented 6 years ago

@slandelle In v1.2.0 we switched to using an internal JVM API to spawn processes on both Linux and Mac. Previously the OS X code used posix_spawn() directly.

The two errors above are:

#define ESRCH           3               /* No such process */
#define EPIPE           32              /* Broken pipe */

My guess is that the process runs fast enough and exits before our call to register kqueue events.

The previous code used a BSD extension to the posix_spawn API that would start the process in a suspended state, and then "resume" the process after we had registered kqueue events.

I may have to consider returning the OS X code to its former state. There was no issue with the OS X code, the refactor was simply to share code between OS X and Linux (which did have issues).

slandelle commented 6 years ago

I guess most people would use MacOS for development and would use Linux for prod where your latest changes shine. So IMHO, it would be best to aim at stability there and revert to what worked before.

brettwooldridge commented 6 years ago

@slandelle Testing changes to current code now to handle fast-exiting processes on OS X. If it ends up not being feasible (but I think it is), I will revert the OS X code.

brettwooldridge commented 6 years ago

@slandelle v1.2.1 has been released.

slandelle commented 6 years ago

@brettwooldridge Thanks a lot, seems to be working fine!!!