github/copilot-sdk · error · IOException
ELF probe too small: + size + bytes
Error message
ELF probe too small: + size + bytes
What it means
readElfPtInterp parses the ELF header and program headers from a small byte probe read from an executable to find PT_INTERP. A probe smaller than 64 bytes cannot even hold the ELF header, so parsing is impossible and an IOException is thrown. This indicates the probe read was truncated or the file is not a real ELF binary.
Solutions
- Increase the probe read size to at least 64 bytes (in practice the constant the library uses, typically 4096+, so PT_INTERP is covered too).
- Verify the target file is a complete ELF binary (file <path> should report 'ELF 64-bit ...'; re-download/reinstall if truncated).
- Ensure the resolver is pointed at the real native executable, not a shell wrapper, symlink to a script, or placeholder.
- Check disk space / read errors that could cause a partial read of the file head.
Example fix
// before
byte[] probe = new byte[16];
try (InputStream in = Files.newInputStream(path)) { in.read(probe); }
// after
byte[] probe = new byte[4096];
try (InputStream in = Files.newInputStream(path)) {
int n = in.readNBytes(probe, 0, probe.length);
if (n < 64) throw new IOException("Truncated ELF header in " + path);
} Defensive patterns
Strategy: validation
Validate before calling
if (Files.size(binaryPath) < 64) {
throw new IOException(binaryPath + " is truncated/corrupt (<64 bytes)");
} Type guard
static boolean looksLikeEligibleBinary(Path p) throws IOException {
return Files.isRegularFile(p) && Files.size(p) >= 64;
} Try / catch
try {
String interp = resolveInterpreter(binaryPath);
} catch (IOException e) {
throw new IOException("Cannot read ELF interpreter from " + binaryPath + ": " + e.getMessage()
+ "; reinstall the native binary", e);
} Prevention
- Verify artifact checksums after download/install to catch truncated binaries early.
- Probe with a large head read (>= 4KiB) rather than a minimal fixed-size array.
- Check `file <path>` reports ELF during install/CI sanity checks.
- Point resolvers at the real ELF binary, not wrapper scripts or placeholders.
When it happens
Trigger: Interpreter resolution reads fewer than 64 bytes from the target file: the file is shorter than 64 bytes (corrupt/placeholder file), the probe read is truncated by a size limit or partial read, or the 'executable' is actually a script/symlink stub with tiny content.
Common situations: A broken install where the native binary is a 0-byte or truncated file; a probe-size constant set too small after a refactor; pointing the resolver at a text wrapper script instead of the ELF binary; a corrupted download.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Program header table offset outside probe window: + phoff
- PT_INTERP extends past probe window; increase probe size
- Not an ELF executable
- Unsupported ELF data encoding: + elfData
- Unsupported ELF class: + elfClass
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/e7ec364d9690e634.
Report an issue: GitHub.
Appendix: source
Thrown at java/sdk/src/main/java/com/github/copilot/ffi/PlatformDetector.java:166
static String detectClassifier(String os, String arch, LinuxLibc linuxLibc) {
LinuxLibc classifierLibc = "linux".equals(os) ? linuxLibc : LinuxLibc.UNKNOWN;
String classifier = CLASSIFIER_BY_KEY.get(new ClassifierKey(os, arch, classifierLibc));
if (classifier == null || !SUPPORTED_CLASSIFIERS.contains(classifier)) {
throw new IllegalStateException(
"Unsupported platform tuple: os=" + os + ", arch=" + arch + ", libc=" + classifierLibc);
}
return classifier;
}
static Set<String> supportedClassifiers() {
return SUPPORTED_CLASSIFIERS;
}
private static String readElfPtInterp(byte[] probe) throws IOException {
int size = probe.length;
if (size < 64) {
throw new IOException("ELF probe too small: " + size + " bytes");
}
if ((probe[0] & 0xFF) != ELF_MAGIC_0 || (probe[1] & 0xFF) != ELF_MAGIC_1 || (probe[2] & 0xFF) != ELF_MAGIC_2
|| (probe[3] & 0xFF) != ELF_MAGIC_3) {
throw new IOException("Not an ELF executable");
}
int elfClass = probe[4] & 0xFF;
int elfData = probe[5] & 0xFF;
if (elfData != ELF_DATA_LITTLE_ENDIAN && elfData != ELF_DATA_BIG_ENDIAN) {
throw new IOException("Unsupported ELF data encoding: " + elfData);
}
boolean littleEndian = elfData == ELF_DATA_LITTLE_ENDIAN;
long phoff;
int phentsize;
int phnum;
int minimumPhentsize;
if (elfClass == ELF_CLASS_64) {View on GitHub (pinned to cd8cf15dc3)