{"record":{"id":"e9912beb0b9b7e2b","repo":"go-delve/delve","slug":"malformed-qmemoryregioninfo-response-packet-error","errorCode":null,"errorMessage":"malformed qMemoryRegionInfo response packet (error): %s","messagePattern":"malformed qMemoryRegionInfo response packet \\(error\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/gdbserial/gdbserver_conn.go","lineNumber":1309,"sourceCode":"\t\t\tmri.start = start\n\t\tcase \"size\":\n\t\t\tsize, err := strconv.ParseUint(string(value), 16, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"malformed qMemoryRegionInfo response packet (size): %v in %s\", err, string(resp))\n\t\t\t}\n\t\t\tmri.size = size\n\t\tcase \"permissions\":\n\t\t\tmri.permissions = string(value)\n\t\tcase \"name\":\n\t\t\tnamestr, ok := decodeHexString(value)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"malformed qMemoryRegionInfo response packet (name): %s\", string(resp))\n\t\t\t}\n\t\t\tmri.name = namestr\n\t\tcase \"error\":\n\t\t\terrstr, ok := decodeHexString(value)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"malformed qMemoryRegionInfo response packet (error): %s\", string(resp))\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"qMemoryRegionInfo error: %s\", errstr)\n\t\t}\n\t}\n\n\treturn mri, nil\n}\n\n// exec executes a message to the stub and reads a response.\n// The details of the wire protocol are described here:\n//\n//\thttps://sourceware.org/gdb/onlinedocs/gdb/Overview.html#Overview\nfunc (conn *gdbConn) exec(cmd []byte, context string) ([]byte, error) {\n\tif err := conn.send(cmd); err != nil {\n\t\treturn nil, err\n\t}\n\treturn conn.recv(cmd, context, false)\n}","sourceCodeStart":1291,"sourceCodeEnd":1327,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver_conn.go#L1291-L1327","documentation":"This error is returned by memoryRegionInfo when the 'error' field of a qMemoryRegionInfo response is not valid hex-encoded ASCII. A stub that reports an error via the 'error' key must hex-encode the error text; decodeHexString failed on it. Delve reports the packet itself as malformed rather than guessing at the error text.","triggerScenarios":"Querying memory region info through the gdbserial backend when the stub replies with an 'error:<value>' key whose value is not valid hex (e.g. plain-text error messages, odd-length or non-hex characters).","commonSituations":"Older or non-conforming stubs that send error descriptions as raw ASCII, stubs reporting unsupported-feature errors (qMemoryRegionInfo not implemented) in the wrong format, embedded debug monitors with hand-rolled responses.","solutions":["Fix the stub to hex-encode the error text per the GDB RSP specification","Check the raw response in the error message to read what the stub actually sent","Verify the stub supports qMemoryRegionInfo at all; if not, disable the dependent feature","Upgrade Delve/target toolchain so both sides agree on the protocol"],"exampleFix":"// stub before (malformed, plain text)\nerror:unsupported\n// stub after (hex-encoded)\nerror:756e737570706f72746564","handlingStrategy":"try-catch","validationCode":"func validHexString(s string) bool {\n    if s == \"\" || len(s)%2 != 0 { return false }\n    _, err := hex.DecodeString(s)\n    return err == nil\n}\n// use: if errorField present && !validHexString(errorField) { /* stub non-conforming */ }","typeGuard":"func hasWellFormedErrorField(resp []byte) (present, wellFormed bool) {\n    for _, kv := range bytes.Split(resp, []byte(\",\")) {\n        parts := bytes.SplitN(kv, []byte(\":\"), 2)\n        if len(parts) == 2 && string(parts[0]) == \"error\" {\n            _, err := hex.DecodeString(string(parts[1]))\n            return true, err == nil\n        }\n    }\n    return false, true\n}","tryCatchPattern":"mri, err := conn.memoryRegionInfo(addr)\nif err != nil {\n    if strings.Contains(err.Error(), \"malformed qMemoryRegionInfo response packet (error)\") {\n        log.Printf(\"stub error field not hex-encoded: %v\", err)\n        return errRegionInfoUnsupported\n    }\n    return err\n}","preventionTips":["Hex-encode error text in stub 'error' fields per the RSP spec","Probe stub capability for qMemoryRegionInfo before issuing queries","Pin to stub versions with conformance-tested error reporting","Inspect raw packets via Delve logging when a new stub misbehaves"],"tags":["gdbserial","protocol","hex-encoding"],"backgroundTag":"malformed-remote-protocol-response","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}