{"record":{"id":"19d155b28704d228","repo":"NationalSecurityAgency/ghidra","slug":"no-mark","errorCode":null,"errorMessage":"No mark","messagePattern":"No mark","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBBufferInputStream.java","lineNumber":108,"sourceCode":"\n\t@Override\n\tpublic int readNBytes(byte[] b, int off, int len) throws IOException {\n\t\treturn read(b, off, len);\n\t}\n\n\t@Override\n\tpublic byte[] readNBytes(int len) throws IOException {\n\t\tlen = Math.min(available(), len);\n\t\tbyte[] result = new byte[len];\n\t\tbuffer.get(offset, result);\n\t\toffset += len;\n\t\treturn result;\n\t}\n\n\t@Override\n\tpublic synchronized void reset() throws IOException {\n\t\tif (mark == -1) {\n\t\t\tthrow new IOException(\"No mark\");\n\t\t}\n\t\toffset = mark;\n\t}\n\n\t@Override\n\tpublic long skip(long n) throws IOException {\n\t\tif (n < 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tn = Math.min(available(), n);\n\t\toffset += n;\n\t\treturn n;\n\t}\n}\n","sourceCodeStart":90,"sourceCodeEnd":123,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/DBBufferInputStream.java#L90-L123","documentation":"Thrown (checked IOException) by DBBufferInputStream.reset() when mark is -1, i.e. mark() was never called (or the mark was invalidated/reset). Per InputStream semantics reset() returns to the marked position; with no mark there is no valid position to return to, so it refuses. mark is initialized to -1 and only set by mark().","triggerScenarios":"Calling reset() before mark() has ever been called on the stream, or after the stream state reset mark back to -1. Mirrors standard java.io.InputStream behavior where reset-without-mark is an error.","commonSituations":"Reusing a DBBufferInputStream and calling reset() assuming a default mark of 0; copy/scan loops that reset without a preceding mark; generic stream-processing code that assumes markSupported()+reset always works.","solutions":["Call mark(readAheadLimit) before reset(); guard reset with a check that mark has been set.","Track whether you have marked (boolean) rather than assuming mark is valid.","If you need to re-read from the start, re-open the stream or seek to offset 0 instead of relying on reset."],"exampleFix":"// before\nin.reset(); // throws IOException \"No mark\"\n\n// after: mark first, and only reset if marked\nin.mark(Integer.MAX_VALUE);\n// ... read ...\nif (wasMarked) {\n    in.reset();\n}","handlingStrategy":"validation","validationCode":"// Only reset if a mark has been set\nif (markWasSet) {\n    in.reset();\n} else {\n    // call in.mark(readAhead) first, or re-open the stream\n}","typeGuard":null,"tryCatchPattern":"try {\n    in.reset();\n} catch (IOException e) {\n    if (\"No mark\".equals(e.getMessage())) { /* mark first, then reset */ }\n    else throw e;\n}","preventionTips":["Always call mark() before reset().","Track a boolean 'marked' flag rather than assuming a default mark.","To re-read from the start, re-open the stream or seek instead of relying on reset."],"tags":["inputstream","mark-reset","dbbuffer","io","checked-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}