NationalSecurityAgency/ghidra · error · IllegalArgumentException
Cannot advance a negative number
Error message
Cannot advance a negative number
What it means
Thrown by AbstractStep.advance(long steps) when steps < 0. advance() only grows a step's tick count, so a negative argument (a request to shrink via advance) is rejected; use rewind() to reduce the count.
Source
Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/time/schedule/AbstractStep.java:86
return tickCount;
}
@Override
public long getPatchCount() {
return 0;
}
@Override
public abstract AbstractStep clone();
/**
* Add to the count of this step
*
* @param steps the count to add
*/
public void advance(long steps) {
if (steps < 0) {
throw new IllegalArgumentException("Cannot advance a negative number");
}
long newCount = tickCount + steps;
if (newCount < 0) {
throw new IllegalArgumentException("Total step count exceeds LONG_MAX");
}
this.tickCount = newCount;
}
@Override
public long rewind(long steps) {
if (steps < 0) {
throw new IllegalArgumentException("Cannot rewind a negative number");
}
long diff = this.tickCount - steps;
this.tickCount = Long.max(0, diff);
return -diff;
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Route reductions through rewind(): if (steps >= 0) advance(steps); else rewind(-steps).
- Ensure the delta passed to advance is non-negative at the call site.
- Prefer TraceSchedule-level APIs that handle direction.
Example fix
// before step.advance(delta); // delta < 0 -> exception // after if (delta >= 0) step.advance(delta); else step.rewind(-delta);
Defensive patterns
Strategy: validation
Validate before calling
if (delta >= 0) step.advance(delta); else step.rewind(-delta);
Type guard
static boolean validAdvance(long steps) { return steps >= 0; } Prevention
- Pick advance vs rewind from the sign of the delta rather than always calling advance.
- Keep a single source of truth for schedule deltas.
When it happens
Trigger: Calling step.advance(n) with a negative n, often because a computed delta was negative.
Common situations: Reusing the same delta for both forward and backward movement; off-by-one in schedule arithmetic producing a negative increment.
Related errors
- Cannot step a negative number
- Total step count exceeds LONG_MAX
- Cannot rewind a negative number
- operandIndex
- Memory addresses cannot be associated with a thread
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/f0aece1a58a25df6.
Report an issue: GitHub.