{"record":{"id":"50eb041719d57172","repo":"go-delve/delve","slug":"architecture-mismatch-between-core-file-x-and","errorCode":null,"errorMessage":"architecture mismatch between core file (%#x) and executable file (%#x)","messagePattern":"architecture mismatch between core file \\(%#x\\) and executable file \\(%#x\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/core/linux_core.go","lineNumber":142,"sourceCode":"\n\tmachineType := coreFile.Machine\n\tnotes, platformIndependentDelveCore, err := readNotes(coreFile, machineType)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\texe, err := os.Open(exePath)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\texeELF, err := elf.NewFile(exe)\n\tif err != nil {\n\t\tif !platformIndependentDelveCore {\n\t\t\treturn nil, nil, err\n\t\t}\n\t} else {\n\t\tif exeELF.Machine != machineType {\n\t\t\treturn nil, nil, fmt.Errorf(\"architecture mismatch between core file (%#x) and executable file (%#x)\", machineType, exeELF.Machine)\n\t\t}\n\t\tif exeELF.Type != elf.ET_EXEC && exeELF.Type != elf.ET_DYN {\n\t\t\treturn nil, nil, fmt.Errorf(\"%v is not an exe file\", exeELF)\n\t\t}\n\t}\n\n\tmemory := buildMemory(coreFile, exeELF, exe, notes)\n\n\t// TODO support 386\n\tvar bi *proc.BinaryInfo\n\tif platformIndependentDelveCore {\n\t\tgoos, goarch, err := platformFromNotes(notes)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tbi = proc.NewBinaryInfo(goos, goarch)\n\t} else if goarch, ok := supportedLinuxMachines[machineType]; ok {\n\t\tbi = proc.NewBinaryInfo(\"linux\", goarch)","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/core/linux_core.go#L124-L160","documentation":"After parsing the core, readLinuxOrPlatformIndependentCore opens the executable ELF and compares e_machine with the core's machine type. A mismatch (e.g. arm64 core with amd64 executable) makes register/memory interpretation impossible, so loading fails with both machine values reported in hex.","triggerScenarios":"readLinuxOrPlatformIndependentCore: exeELF opens successfully but exeELF.Machine != machineType from the core's ELF header — cross-architecture core/exe pair supplied to the core loader.","commonSituations":"Debugging a core captured on another machine/architecture (e.g. from CI or production on ARM) with a locally built x86-64 binary; wrong binary chosen from a multi-arch build directory.","solutions":["Provide the executable built for the same GOARCH as the core (compare with 'file core' and 'file exe').","Cross-compile the matching binary: GOARCH=<core arch> go build and rerun.","Run delve itself on/for the matching architecture.","Verify with 'readelf -h': Machine fields of both files must match."],"exampleFix":"// before\nGOOS=linux GOARCH=amd64 go build -o app .  # core is arm64\n// after\nGOOS=linux GOARCH=arm64 go build -o app .  # matches core architecture","handlingStrategy":"validation","validationCode":"coreELF, _ := elf.Open(corePath)\nexeELF, _ := elf.Open(exePath)\nif coreELF.Machine != exeELF.Machine {\n\treturn fmt.Errorf(\"arch mismatch: core=%v exe=%v\", coreELF.Machine, exeELF.Machine)\n}","typeGuard":"func archMatches(corePath, exePath string) bool {\n\tc, err1 := elf.Open(corePath)\n\tif err1 != nil { return false }\n\tdefer c.Close()\n\te, err2 := elf.Open(exePath)\n\tif err2 != nil { return false }\n\tdefer e.Close()\n\treturn c.Machine == e.Machine\n}","tryCatchPattern":"p, err := core.ReadFile(exePath, corePath)\nif err != nil && strings.Contains(err.Error(), \"architecture mismatch\") {\n\treturn fmt.Errorf(\"rebuild the exe for the core's GOARCH (see 'readelf -h <core>')\")\n}","preventionTips":["Keep binaries from the exact machine that produced the core.","For cross-arch analysis, cross-compile with matching GOARCH.","Record GOARCH alongside dumps in CI/prod workflows.","Compare 'readelf -h' Machine fields of both files first."],"tags":["core-dump","architecture-mismatch","elf-format"],"backgroundTag":"architecture-mismatch","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}