Ghidra is a software reverse engineering (SRE) framework
Fixed decompiler timeout bug introduced in recent change
dragonmacher9b0e2dc24b24
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileProcess.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileProcess.javaindex 3e568ce925..7ee0b10dd8 100644--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileProcess.java+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileProcess.java@@ -28,7 +28,7 @@ import ghidra.util.timer.GTimer;import ghidra.util.timer.GTimerMonitor;/**- *+ *** Class for communicating with a single decompiler process.* The process controls decompilation for a single Program.@@ -116,7 +116,7 @@ public class DecompileProcess {}if (nativeProcess != null) {// Something bad happened to the process or the interface- // and now we try to restart+ // and now we try to restartnativeProcess.destroy(); // Make sure previous bad process is killednativeProcess = null;}@@ -141,7 +141,7 @@ public class DecompileProcess {private int readToBurst() throws IOException {if (nativeIn == null) {- // we've been disposed!+ // we've been disposed!// (not sure if throwing an exception the best)throw new IOException("Decompiler disposed!");}@@ -525,12 +525,14 @@ public class DecompileProcess {*/public synchronized LimitedByteBuffer sendCommand1ParamTimeout(String command, String param,int timeoutSecs) throws IOException, DecompileException {+if (!statusGood) {throw new IOException(command + " called on bad process");}+LimitedByteBuffer resbuf = null;- GTimerMonitor timerMonitor = GTimer.scheduleRunnable(timeoutSecs * 1000, timeoutRunnable);-// GTimerMonitor timerMonitor = GTimer.scheduleRunnable(100 * timeoutSecs * 1000, timeoutRunnable); //epp change timeout for valgrind+ int validatedTimeoutMs = getTimeoutMs(timeoutSecs);+ GTimerMonitor timerMonitor = GTimer.scheduleRunnable(validatedTimeoutMs, timeoutRunnable);try {write(command_start);@@ -554,6 +556,13 @@ public class DecompileProcess {return resbuf;}+ private int getTimeoutMs(int timeoutSecs) {+ if (timeoutSecs == 0) {+ return -1;+ }+ return timeoutSecs * 1000;+ }+/*** Send a command with 2 parameters to the decompiler and read the result* @param command string to senddiff --git a/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskDialog.java b/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskDialog.javaindex 5994b56deb..4803a3be21 100644--- a/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskDialog.java+++ b/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskDialog.java@@ -220,12 +220,17 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {}/**- * Shows the dialog window centered on the parent window.- * Dialog display is delayed if delay greater than zero.+ * Shows the dialog window centered on the parent window. Dialog display is delayed if delay+ * greater than zero.+ ** @param delay number of milliseconds to delay displaying of the task dialog. If the delay is* greater than {@link #MAX_DELAY}, then the delay will be {@link #MAX_DELAY};+ * @throws IllegalArgumentException if {@code delay} is negative*/public void show(int delay) {+ if (delay < 0) {+ throw new IllegalArgumentException("Task Dialog delay cannot be negative");+ }if (isModal()) {doShowModal(delay);}