brettwooldridge / NuProcess

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

Issues with FreeBSD 11.3 and OpenJDK (BitBucket) #108

Open jasonkafer opened 4 years ago

jasonkafer commented 4 years ago

We recently upgraded BitBucket to 7.1.0 which now utilizes the NuProcess 2.0.0 library. We are getting the following exception on Freebsd 11.3 using OpenJDK8 and OpenJDK11

java.lang.RuntimeException: syscall(SYS__pthread_chdir) failed to set current directory, return code: -1, last error: 45 at com.zaxxer.nuprocess.internal.BasePosixProcess.checkReturnCode(BasePosixProcess.java:648) at com.zaxxer.nuprocess.osx.OsxProcess.spawnWithCwd(OsxProcess.java:185) at com.zaxxer.nuprocess.osx.OsxProcess.prepareProcess(OsxProcess.java:151) at com.zaxxer.nuprocess.osx.OsxProcess.run(OsxProcess.java:107) at com.zaxxer.nuprocess.osx.OsxProcessFactory.runProcess(OsxProcessFactory.java:43) at com.zaxxer.nuprocess.NuProcessBuilder.run(NuProcessBuilder.java:273) at com.atlassian.bitbucket.internal.process.nu.NuNioProcessHelper.run(NuNioProcessHelper.java:75)

jasonkafer commented 4 years ago

After digging into the code, it appears that the issue on FreeBSD is due to the value that is set for the SYS___pthread_chdir value in LibC.java

I am not sure where the value of 348 comes from, but based on the FreeBSD syscall.h (https://github.com/freebsd/freebsd/blob/master/sys/sys/syscall.h) the correct value to pass here is 12. I made a custom build of the library and replaced the library in bitbucket and all is good.

I'll submit a pull request for the change.

jasonkafer commented 4 years ago

Pull request submitted