github/copilot-sdk · error · IOException

Empty PT_INTERP segment

Error message

Empty PT_INTERP segment

What it means

A valid PT_INTERP segment contains a NUL-terminated interpreter path (e.g. /lib64/ld-linux-x86-64.so.2). If the first byte of the segment is already NUL, the path is empty, which cannot be a real interpreter, so an IOException is thrown instead of returning an empty string.

Solutions

  1. Validate the binary with `readelf -l <path>`; a real binary shows a non-empty interpreter — if so, fix your probe/decode logic (full read from offset 0, correct endianness).
  2. Reinstall/re-download the binary and verify its checksum.
  3. Reject corrupt/untrusted ELF inputs explicitly by catching IOException and reporting the file as invalid.
  4. Check that p_offset/p_filesz were decoded after correctly determining ELF class and endianness.

Example fix

// before
String interp = readElfPtInterp(probe); // decodes p_offset with wrong endianness
// after
boolean littleEndian = (probe[5] & 0xFF) == 1; // EI_DATA before decoding
long pOffset = littleEndian ? readUInt32LE(probe, base + 8) : readUInt32BE(probe, base + 8);
String interp = readElfPtInterp(probe);
Defensive patterns

Strategy: validation

Validate before calling

// Reject obviously invalid ELF before parsing
if (!isElf(probe) || probe.length < 64) throw new IOException("Invalid or corrupt ELF input");

Type guard

static boolean isElf(byte[] probe) {
    return probe != null && probe.length >= 4 && probe[0] == 0x7F
        && probe[1] == 'E' && probe[2] == 'L' && probe[3] == 'F';
}

Try / catch

try {
    String interp = readElfPtInterp(probe);
    if (interp.isEmpty()) throw new IOException("Empty PT_INTERP");
} catch (IOException e) {
    throw new IOException("Corrupt ELF interpreter segment in " + path + ": " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: A PT_INTERP entry whose p_filesz starts with a 0 byte at p_offset — a corrupt or adversarially crafted ELF, or misaligned decoding of program header fields from a bad probe.

Common situations: Corrupted binaries; fuzzed ELF inputs; header fields decoded with wrong endianness/class so p_offset points at padding instead of the .interp content.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/28a770216ea7ffaf. Report an issue: GitHub.

Appendix: source

Thrown at java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java:245

                pFileSize = readUInt32(probe, base + 16, littleEndian);
            }

            if (pOffset < 0 || pFileSize <= 0 || pOffset > Integer.MAX_VALUE || pFileSize > Integer.MAX_VALUE) {
                throw new IOException("Invalid PT_INTERP bounds");
            }

            int start = (int) pOffset;
            int end = start + (int) pFileSize;
            if (end > size) {
                throw new IOException("PT_INTERP extends past probe window; increase probe size");
            }

            int nulIndex = start;
            while (nulIndex < end && probe[nulIndex] != 0) {
                nulIndex++;
            }
            if (nulIndex == start) {
                throw new IOException("Empty PT_INTERP segment");
            }
            return new String(probe, start, nulIndex - start, StandardCharsets.UTF_8);
        }

        throw new IOException("ELF PT_INTERP segment not found");
    }

    private static byte[] readPrefix(Path path, int maxBytes) throws IOException {
        byte[] buffer = new byte[maxBytes];
        int total = 0;
        try (InputStream in = Files.newInputStream(path)) {
            while (total < maxBytes) {
                int read = in.read(buffer, total, maxBytes - total);
                if (read < 0) {
                    break;
                }
                total += read;
            }

View on GitHub (pinned to cd8cf15dc3)