{"record":{"id":"ad1f92b25cf5a5af","repo":"go-delve/delve","slug":"malformed-qmemoryregioninfo-response-packet-name","errorCode":null,"errorMessage":"malformed qMemoryRegionInfo response packet (name): %s","messagePattern":"malformed qMemoryRegionInfo response packet \\(name\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/gdbserial/gdbserver_conn.go","lineNumber":1303,"sourceCode":"\t\tswitch string(key) {\n\t\tcase \"start\":\n\t\t\tstart, 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 (start): %v in %s\", err, string(resp))\n\t\t\t}\n\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","sourceCodeStart":1285,"sourceCodeEnd":1321,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver_conn.go#L1285-L1321","documentation":"This error is returned by memoryRegionInfo when the 'name' field of a qMemoryRegionInfo response is not valid hex-encoded ASCII. The GDB RSP requires optional string fields like the region name to be hex-encoded; decodeHexString failed on the value. Delve rejects the entire response instead of returning a region with a corrupt name.","triggerScenarios":"Calling memory region info queries via the gdbserial backend when the stub's qMemoryRegionInfo reply contains 'name:<value>' where value is not a valid hex string (odd-length hex, non-hex characters, or raw unencoded text).","commonSituations":"Stubs that send the mapping name as plain text (e.g. name:/lib/x.so) instead of hex-encoding it, stubs that send name: with an empty or binary payload, or protocol translations proxies that alter the field.","solutions":["Fix the stub to hex-encode the region name (e.g. name:2f6c69622f782e736f for '/lib/x.so')","Compare with the response captured in the error message to confirm the encoding problem","If the name is optional for your use, use a stub build that omits the name field entirely","Patch decodeHexString tolerance is not an option upstream; prefer fixing the server side"],"exampleFix":"// stub before (malformed, plain text)\nname:/lib/x.so\n// stub after (hex-encoded)\nname:2f6c69622f782e736f","handlingStrategy":"validation","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 !validHexString(nameField) { /* name is not RSP hex-encoded */ }","typeGuard":"func regionNameIsHexEncoded(resp []byte) bool {\n    for _, kv := range bytes.Split(resp, []byte(\",\")) {\n        parts := bytes.SplitN(kv, []byte(\":\"), 2)\n        if len(parts) == 2 && string(parts[0]) == \"name\" {\n            _, err := hex.DecodeString(string(parts[1]))\n            return err == nil\n        }\n    }\n    return false\n}","tryCatchPattern":"mri, err := conn.memoryRegionInfo(addr)\nif err != nil {\n    if strings.Contains(err.Error(), \"malformed qMemoryRegionInfo response packet (name)\") {\n        log.Printf(\"stub sent non-hex-encoded name: %v\", err)\n        mri = &memoryRegionInfo{} // proceed without name\n    } else {\n        return err\n    }\n}","preventionTips":["Hex-encode all string-valued fields in custom stub implementations (name, error)","Test stubs against real gdbserver behavior for optional string fields","Omit optional fields entirely rather than sending them in the wrong encoding","Review GDB RSP documentation for qMemoryRegionInfo field encoding rules"],"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"}