NationalSecurityAgency/ghidra · error · IllegalArgumentException
Base compiler spec cannot be a guest compiler spec
Error message
Base compiler spec cannot be a guest compiler spec
What it means
addGuestPlatform rejects adding the trace's own base compiler spec as a guest: if trace.getBaseCompilerSpec() == compilerSpec it throws IllegalArgumentException("Base compiler spec cannot be a guest compiler spec"). A platform cannot guest-host itself.
Source
Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTracePlatformManager.java:327
}
protected DBTraceGuestPlatform doAddGuestPlatform(CompilerSpec compilerSpec) {
DBTraceGuestPlatform platformEntry = platformStore.create();
platformEntry.set(compilerSpec);
try {
platformEntry.loadDataTypeManager(OpenMode.CREATE, TaskMonitor.DUMMY);
}
catch (CancelledException | VersionException | IOException e) {
throw new AssertionError(e);
}
platformsByCompiler.put(compilerSpec, platformEntry);
return platformEntry;
}
@Override
public DBTraceGuestPlatform addGuestPlatform(CompilerSpec compilerSpec) {
if (trace.getBaseCompilerSpec() == compilerSpec) {
throw new IllegalArgumentException(
"Base compiler spec cannot be a guest compiler spec");
}
DBTraceGuestPlatform platform;
try (LockHold hold = LockHold.lock(lock.writeLock())) {
platform = doAddGuestPlatform(compilerSpec);
}
trace.setChanged(new TraceChangeRecord<>(TraceEvents.PLATFORM_ADDED, null, platform));
return platform;
}
@Override
public InternalTracePlatform getPlatform(CompilerSpec compilerSpec) {
try (LockHold hold = LockHold.lock(lock.readLock())) {
if (trace.getBaseCompilerSpec() == compilerSpec) {
return hostPlatform;
}
return platformsByCompiler.get(compilerSpec);
}View on GitHub (pinned to d5f144c24d)
Solutions
- Skip the base compiler spec when enumerating candidate specs.
- Pass a CompilerSpec from a different language than the host.
- Guard with trace.getBaseCompilerSpec() == compilerSpec before the call.
Example fix
// before
for (CompilerSpec cs : lang.getCompilerSpecs()) {
mgr.addGuestPlatform(cs);
}
// after
CompilerSpec base = trace.getBaseCompilerSpec();
for (CompilerSpec cs : lang.getCompilerSpecs()) {
if (cs == base) continue;
mgr.addGuestPlatform(cs);
} Defensive patterns
Strategy: validation
Validate before calling
CompilerSpec base = trace.getBaseCompilerSpec();
for (CompilerSpec cs : candidateSpecs) {
if (cs == base) continue; // cannot add host's own as guest
mgr.addGuestPlatform(cs);
} Prevention
- Filter out the host's base compiler spec when enumerating guest candidates.
- Use reference equality (==) to compare the base compiler spec, matching the source check.
- Document that guest platforms must target a different language than the host.
When it happens
Trigger: Calling addGuestPlatform with the host trace's base CompilerSpec; enumerating a language's compiler specs and not excluding the host's own.
Common situations: Looping over CompilerSpecs and passing the base one through; copy-paste mapping setup; confusing host and guest configuration.
Related errors
- Invalid number of elements specified: {}
- pos cannot be less than zero
- %s: unknown demangling style `%s'
- Max ascii string size is %d you provided: %lu chars. Exiting
- need even-number of ascii chars for byte-stream: (offset: %0
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/a97e506d04c86ba5.
Report an issue: GitHub.