7
votes

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)

1
It looks like your path is a bit mangled: EXEpath\bin\7za.exe ? maybe you accidentally typed something in a place you shouldn't have :-)Ivonet
Please ignore that location. That is not the actual location.Aravindharaj G
Does the exes work if you start them manually ? (by double clicking on them)Asoub
How does your Java program run? As a service? This is kind of important info. so are Win version, Java version. Can you reproduce it manually? What do you mean that with another jvm it works? does the java process live through those 2 - 3 days? did you monitor its memory, threads, and other characteristics (from TaskMgr)?CristiFati
Do you call a lot of these processes? It appears from github.com/moliva/proactive/blob/master/src/Extensions/org/… that you're "running out of non interactive desktop heap" do you see the 7za processes exiting after you call them, in task manager? thought for work around: call a batch file that calls 7za.exe, possibly call #inheritIO GL!rogerdpack

1 Answers

0
votes

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.