EXE crash when calling from ProcessBuilder in java

7

I am invoking some EXE's(7za.exe, pg_basebackup.exe, ...) from JAVA ProcessBuilder. It is working without any issues for 2 or 3 days (EXE will be called daily). After that EXE's are crashing continuously.

7za.exe error:
Exit code :: -1.073.741.502

Windows Event log error:
Faulting application name: 7za.exe, version: 9.20.0.0, time stamp: 0x4ce553f5 Faulting module name: KERNELBASE.dll, version: 6.2.9200.21941, time stamp: 0x5792e533
Exception code: 0xc0000142
Fault offset: 0x000683ba
Faulting process id: 0x10bc
Faulting application start time: 0x01d2cebdff3bb05a
Faulting application path: EXEpath\bin\7za.exe
Faulting module path: KERNELBASE.dll
Report Id: 3d27046a-3ab1-11e7-93fe-00505680156e
Faulting package full name:
Faulting package-relative application ID:

Code snippet

File workingDir = new File(workingDirectory);
ProcessBuilder pb = new ProcessBuilder(argumentsList);
pb.redirectErrorStream(true);
pb.directory(workingDir);        
Process process = pb.start();
BufferedReader commandOutput = new BufferedReader(new 
InputStreamReader(process.getInputStream()));
String s = null;
while ((s = commandOutput.readLine()) != null) {
    print(s);
}
int exitCode = process.exitValue();

Also it is not happening in all the machines which run this code. Is it any memory leakage OR OS level error? Please advise.

Thanks in advance.

Edit 1: Same kind of error in c#. It also contains fix.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/cb9a15ed-4401-47f1-8c78-0c63c3da677d/process-returns-0xc0000142-when-started-from-a-windows-service-prividing-the-credentials?forum=clr
How to achieve it in java?

Edit 2: Java is running as a service (using wrapper)
Java version : 1.0.051
Windows version : Windows server 2012 and R2(64bit), Windows 7(64bit), Windows 8(64bit)

java
windows
exe
processbuilder
asked on Stack Overflow Dec 11, 2017 by Aravindharaj G • edited Jan 18, 2018 by Aravindharaj G

1 Answer

0

So I agree with the comments above asking for additional detail to identify the underlying cause of this issue (number of processes when the issues occurs, metrics of the instance, etc). Generally speaking I would argue that it is an anti-pattern to call an executable from java if you can avoid it. In this case I would recommend you try to replace the call to the executable with something like the 7-zip binding.

This should provide you better insight into how the underlying processes are performing and would move ownership and management of the processes under the JVM.

answered on Stack Overflow Jan 15, 2018 by Tristan

User contributions licensed under CC BY-SA 3.0