{"record":{"id":"48a33102555e7c54","repo":"go-delve/delve","slug":"malformed-qmemoryregioninfo-response-packet-start","errorCode":null,"errorMessage":"malformed qMemoryRegionInfo response packet (start): %v in %s","messagePattern":"malformed qMemoryRegionInfo response packet \\(start\\): (.+?) in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/gdbserial/gdbserver_conn.go","lineNumber":1289,"sourceCode":"func (conn *gdbConn) memoryRegionInfo(addr uint64) (*memoryRegionInfo, error) {\n\tconn.outbuf.Reset()\n\tfmt.Fprintf(&conn.outbuf, \"$qMemoryRegionInfo:%x\", addr)\n\tresp, err := conn.exec(conn.outbuf.Bytes(), \"qMemoryRegionInfo\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmri := &memoryRegionInfo{}\n\n\tcsp := colonSemicolonParser{buf: resp}\n\tfor csp.next() {\n\t\tkey, value := csp.key, csp.value\n\n\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)","sourceCodeStart":1271,"sourceCodeEnd":1307,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/gdbserial/gdbserver_conn.go#L1271-L1307","documentation":"This error is returned by memoryRegionInfo in Delve's gdbserial backend when the 'start' field of a qMemoryRegionInfo response packet cannot be parsed as a 64-bit hex integer. The GDB Remote Serial Protocol stub replied to the qMemoryRegionInfo query, but its 'start:<hex>' value was not valid hexadecimal. Delve treats any unparseable field as a malformed packet and aborts rather than returning a partially-filled memory region.","triggerScenarios":"Calling any Delve API that queries memory region info (e.g. breakpoints/memory validation paths that call c.memoryRegionInfo) against a gdbserial target when the remote stub sends a qMemoryRegionInfo response whose 'start' value fails strconv.ParseUint(value, 16, 64).","commonSituations":"Connecting to a non-standard or buggy GDB RSP stub, a custom/lite debugger server that formats addresses with a 0x prefix or decimal instead of bare hex, a stub emitting an empty or truncated start field, or a protocol-incompatible firmware monitor stub.","solutions":["Update or fix the remote gdbserial stub so 'start' is emitted as bare lowercase hex without 0x prefix (e.g. start:7fff0000)","Check the raw packet in the error message (%s holds the full response) to see exactly what the stub sent","Verify you are connecting to a supported target; try the native backend instead of gdbserial where possible","Report the issue to the stub vendor/upstream if the response violates the GDB RSP specification"],"exampleFix":"// stub before (malformed)\nstart:0x7fff0000\n// stub after (valid GDB RSP hex)\nstart:7fff0000","handlingStrategy":"validation","validationCode":"// Validate that the stub's qMemoryRegionInfo reply uses bare hex before relying on it.\nfunc validHex(s string) bool {\n    if s == \"\" || len(s)%2 != 0 { return false }\n    for _, r := range s {\n        if !((r >= '0' && r <= '9') || (r >= 'a' && r <= 'f') || (r >= 'A' && r <= 'F')) { return false }\n    }\n    return true\n}\n// use: if !validHex(startField) { /* stub is non-conforming; avoid region queries */ }","typeGuard":"func isMemoryRegionInfoPacket(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]) == \"start\" {\n            _, err := strconv.ParseUint(string(parts[1]), 16, 64)\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 (start)\") {\n        log.Printf(\"stub sent invalid start field: %v\", err)\n        // fall back to assuming full-address-space or skipping the feature\n        return nil\n    }\n    return err\n}","preventionTips":["Use supported gdbserver/stub versions with conforming qMemoryRegionInfo responses","Log raw RSP traffic (Delve's --log output) when integrating a new stub","Test stub responses against the GDB Remote Serial Protocol spec before production use","Prefer the native backend when local debugging removes the stub from the picture"],"tags":["gdbserial","protocol","hex-parsing"],"backgroundTag":"malformed-remote-protocol-response","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}