Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Another attempt to resolve CI hangs.

Danceedbe6c9fcb
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/model/AbstractModelForGdbAttacherTest.java b/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/model/AbstractModelForGdbAttacherTest.java
index 6c6423dc82..bdd7b7143f 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/model/AbstractModelForGdbAttacherTest.java
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/model/AbstractModelForGdbAttacherTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
+import ghidra.async.AsyncUtils.TemperamentalRunnable;
import ghidra.dbg.target.TargetEnvironment;
import ghidra.dbg.target.TargetMethod.TargetParameterMap;
import ghidra.dbg.test.AbstractDebuggerModelAttacherTest;
@@ -49,4 +50,35 @@ public abstract class AbstractModelForGdbAttacherTest extends AbstractDebuggerMo
assertEquals("little", environment.getEndian());
assertTrue(environment.getDebugger().toLowerCase().contains("gdb"));
}
+
+ // NB. Gradle/Java hangs on process clean-up if target is still attached
+ protected void withDetachAndForcefulDummyDestruction(TemperamentalRunnable test)
+ throws Throwable {
+ try {
+ test.run();
+ runTestDetach(getAttachSpecimen());
+ }
+ finally {
+ if (dummy == null) {
+ return;
+ }
+ dummy.process.destroy();
+ dummy.process.destroyForcibly();
+ }
+ }
+
+ @Override
+ public void testAttachByObj() throws Throwable {
+ withDetachAndForcefulDummyDestruction(() -> super.testAttachByObj());
+ }
+
+ @Override
+ public void testAttachByPid() throws Throwable {
+ withDetachAndForcefulDummyDestruction(() -> super.testAttachByPid());
+ }
+
+ @Override
+ public void testAttachByPidThenResumeInterrupt() throws Throwable {
+ withDetachAndForcefulDummyDestruction(() -> super.testAttachByPidThenResumeInterrupt());
+ }
}
diff --git a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java
index 07a4638d23..a91b73da92 100644
--- a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java
+++ b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java
@@ -16,10 +16,12 @@
package ghidra.dbg.testutil;
import java.io.*;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import ghidra.framework.Application;
+import ghidra.util.Msg;
public class DummyProc implements AutoCloseable {
public final Process process;
@@ -65,11 +67,13 @@ public class DummyProc implements AutoCloseable {
.start();
pid = process.pid();
+ Msg.info(this, "Started dummy process pid = " + pid + ": " + List.of(args));
}
@Override
public void close() throws Exception {
if (!process.destroyForcibly().waitFor(1000, TimeUnit.MILLISECONDS)) {
+ Msg.error(this, "Could not terminate process " + pid);
throw new TimeoutException("Could not terminate process " + pid);
}
}