{"record":{"id":"35a7882e55948138","repo":"NationalSecurityAgency/ghidra","slug":"total-step-count-exceeds-long-max","errorCode":null,"errorMessage":"Total step count exceeds LONG_MAX","messagePattern":"Total step count exceeds LONG_MAX","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/time/schedule/AbstractStep.java","lineNumber":90,"sourceCode":"\tpublic long getPatchCount() {\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic abstract AbstractStep clone();\n\n\t/**\n\t * Add to the count of this step\n\t * \n\t * @param steps the count to add\n\t */\n\tpublic void advance(long steps) {\n\t\tif (steps < 0) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot advance a negative number\");\n\t\t}\n\t\tlong newCount = tickCount + steps;\n\t\tif (newCount < 0) {\n\t\t\tthrow new IllegalArgumentException(\"Total step count exceeds LONG_MAX\");\n\t\t}\n\t\tthis.tickCount = newCount;\n\t}\n\n\t@Override\n\tpublic long rewind(long steps) {\n\t\tif (steps < 0) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot rewind a negative number\");\n\t\t}\n\t\tlong diff = this.tickCount - steps;\n\t\tthis.tickCount = Long.max(0, diff);\n\t\treturn -diff;\n\t}\n\n\t@Override\n\tpublic boolean isCompatible(Step step) {\n\t\tif (!(step.getClass() == this.getClass())) {\n\t\t\treturn false;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/time/schedule/AbstractStep.java#L72-L108","documentation":"Thrown by AbstractStep.advance(long steps) when the new total tickCount + steps overflows a signed long (detected because the result wrapped to negative). This protects against silent overflow in schedule step counts which are used as execution limits.","triggerScenarios":"Calling advance(steps) where tickCount + steps > Long.MAX_VALUE, e.g. repeatedly advancing an already-large step, or passing an extremely large steps value.","commonSituations":"Aggregating/looping many advances without bounds; parsing an unbounded schedule; test inputs with Long.MAX_VALUE deltas.","solutions":["Cap the desired step count at Long.MAX_VALUE rather than advancing beyond it.","Check overflow explicitly before advancing: if (Long.MAX_VALUE - step.getTickCount() < steps) clamp.","Reconsider why the count is so large; schedules are bounded by real execution time."],"exampleFix":"// before\nstep.advance(hugeDelta);\n\n// after\nlong headroom = Long.MAX_VALUE - step.getTickCount();\nstep.advance(Math.min(hugeDelta, headroom));","handlingStrategy":"validation","validationCode":"long headroom = Long.MAX_VALUE - step.getTickCount();\nstep.advance(Math.min(steps, headroom));","typeGuard":"static boolean advanceFits(long cur, long add) { return add >= 0 && Long.MAX_VALUE - cur >= add; }","tryCatchPattern":null,"preventionTips":["Cap aggregate step counts at Long.MAX_VALUE.","Bound loops that accumulate advances.","Reconsider any path that approaches Long.MAX_VALUE ticks."],"tags":["ghidra","trace-modeling","schedule","step","overflow","illegal-argument"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}