{"record":{"id":"dae885de8f1068b9","repo":"go-delve/delve","slug":"could-not-read-string-at-v-due-to-s","errorCode":null,"errorMessage":"could not read string at %#v due to %s","messagePattern":"could not read string at %#v due to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":1568,"sourceCode":"\t\t\t\treturn 0, 0, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn outaddr, strlen, nil\n}\n\nfunc readStringValue(mem MemoryReadWriter, addr uint64, strlen int64, cfg LoadConfig) (string, error) {\n\tif strlen == 0 {\n\t\treturn \"\", nil\n\t}\n\n\tcount := min(strlen, int64(cfg.MaxStringLen))\n\n\tval := make([]byte, int(count))\n\t_, err := mem.ReadMemory(val, addr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not read string at %#v due to %s\", addr, err)\n\t}\n\n\treturn string(val), nil\n}\n\nfunc readCStringValue(mem MemoryReadWriter, addr uint64, cfg LoadConfig) (string, bool, error) {\n\tbuf := make([]byte, cfg.MaxStringLen) //\n\tval := buf[:0]                        // part of the string we've already read\n\n\tfor len(buf) > 0 {\n\t\t// Reads some memory for the string but (a) never more than we would\n\t\t// need (considering cfg.MaxStringLen), and (b) never cross a page boundary\n\t\t// until we're sure we have to.\n\t\t// The page check is needed to avoid getting an I/O error for reading\n\t\t// memory we don't even need.\n\t\t// We don't know how big a page is but 1024 is a reasonable minimum common\n\t\t// divisor for all architectures.\n\t\tcuraddr := addr + uint64(len(val))","sourceCodeStart":1550,"sourceCodeEnd":1586,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L1550-L1586","documentation":"Delve read the string header successfully but the subsequent `ReadMemory` of the string's `min(strlen, MaxStringLen)` bytes at the data address failed. The address and the underlying error are both included in the message.","triggerScenarios":"Evaluating a string whose data pointer targets unmapped/freed memory; occurs in `readStringValue` after a successful header read when `mem.ReadMemory(val, addr)` fails.","commonSituations":"Dangling string pointers to freed heap (memory returned to the OS); core dumps missing the data pages; remote debugging where the target region is not accessible; nil or corrupted data pointer that survived the `addr == 0` check due to reads racing with the target.","solutions":["Check the data address in the message and verify it is mapped (inspect memory maps).","Re-evaluate after the goroutine/stack state is stable; heap may have moved if the target was running.","For core dumps, ensure the heap pages were captured.","If MaxStringLen truncation is involved, still verify the base address separately; truncation does not cause this error."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// (dlv) print uintptr(str)  // validate the data pointer is non-nil and plausible\n// (dlv) print str.len       // sanity-check the length","typeGuard":null,"tryCatchPattern":"// In delve CLI, inspect the raw address instead:\n// (dlv) print (*[64]byte)(unsafe.Pointer(uintptr(str)))\n// to see whether the region is readable at all.","preventionTips":["Watch for dangling string pointers into freed heap.","Use complete-memory core dumps for post-mortem debugging.","Re-evaluate after the target stops; running targets race with reads.","Raise MaxStringLen only after confirming the base address is valid."],"tags":["debugger","go","string","memory-read"],"backgroundTag":"string-data-unreadable","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}