{"record":{"id":"7a02574f55f075d9","repo":"github/copilot-sdk","slug":"pt-interp-extends-past-probe-window-increase-prob","errorCode":null,"errorMessage":"PT_INTERP extends past probe window; increase probe size","messagePattern":"PT_INTERP extends past probe window; increase probe size","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java","lineNumber":237,"sourceCode":"\n            long pOffset;\n            long pFileSize;\n            if (elfClass == ELF_CLASS_64) {\n                pOffset = readUInt64(probe, base + 8, littleEndian);\n                pFileSize = readUInt64(probe, base + 32, littleEndian);\n            } else {\n                pOffset = readUInt32(probe, base + 4, littleEndian);\n                pFileSize = readUInt32(probe, base + 16, littleEndian);\n            }\n\n            if (pOffset < 0 || pFileSize <= 0 || pOffset > Integer.MAX_VALUE || pFileSize > Integer.MAX_VALUE) {\n                throw new IOException(\"Invalid PT_INTERP bounds\");\n            }\n\n            int start = (int) pOffset;\n            int end = start + (int) pFileSize;\n            if (end > size) {\n                throw new IOException(\"PT_INTERP extends past probe window; increase probe size\");\n            }\n\n            int nulIndex = start;\n            while (nulIndex < end && probe[nulIndex] != 0) {\n                nulIndex++;\n            }\n            if (nulIndex == start) {\n                throw new IOException(\"Empty PT_INTERP segment\");\n            }\n            return new String(probe, start, nulIndex - start, StandardCharsets.UTF_8);\n        }\n\n        throw new IOException(\"ELF PT_INTERP segment not found\");\n    }\n\n    private static byte[] readPrefix(Path path, int maxBytes) throws IOException {\n        byte[] buffer = new byte[maxBytes];\n        int total = 0;","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java#L219-L255","documentation":"The PT_INTERP segment (p_offset + p_filesz) must lie entirely within the bytes probed from the file, because the interpreter path string is read from the probe. If the segment extends past the probe window, the probe is too small and an IOException is thrown telling the caller to enlarge it.","triggerScenarios":"The probe covers the ELF header but not the full PT_INTERP segment — common when the interpreter path (.interp section content, e.g. long glibc paths) sits at a file offset beyond the probe size, or the read was truncated.","commonSituations":"Binaries with long interpreter paths (e.g. custom glibc under /opt/...) located late in the file combined with a small fixed probe size; head-only reads of large binaries; partial downloads.","solutions":["Increase the probe size (e.g. 4–64 KiB, or min(fileSize, 1MiB)) so the whole PT_INTERP segment is captured.","Fall back to reading the entire file when the head probe fails this check.","Verify the file is complete: compare size and checksum against the published artifact.","Extract the interpreter with `readelf -l <path> | grep interpreter` to confirm the path length and roughly where it sits in the file."],"exampleFix":"// before\nbyte[] probe = new byte[256];\nreadFully(path, probe);\n// after\nlong fileSize = Files.size(path);\nbyte[] probe = readHead(path, (int) Math.min(fileSize, 65536));","handlingStrategy":"try-catch","validationCode":"long fileSize = Files.size(path);\nbyte[] probe = readHead(path, (int) Math.min(fileSize, 1 << 20)); // generous head read","typeGuard":null,"tryCatchPattern":"try {\n    String interp = readElfPtInterp(probe);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"probe window\")) {\n        probe = Files.readAllBytes(path);          // retry with full file\n        interp = readElfPtInterp(probe);\n    } else throw e;\n}","preventionTips":["Use a large probe (>= 64KiB) to cover long interpreter paths late in the file.","Fall back to a full-file read when head-only parsing fails.","Verify artifact size and checksum after download.","Test against binaries with long/custom interpreter paths (e.g. /opt/glibc/...)."],"tags":["elf","binary-parsing","file-io","java"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}