{"record":{"id":"4a72a1a734ea4898","repo":"go-delve/delve","slug":"could-not-read-string-len-s","errorCode":null,"errorMessage":"could not read string len %s","messagePattern":"could not read string len (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":1539,"sourceCode":"\treturn dstv.writeEmptyInterface(typeAddr, srcv)\n}\n\nfunc readStringInfo(mem MemoryReadWriter, arch *Arch, addr uint64, typ *godwarf.StringType) (uint64, int64, error) {\n\t// string data structure is always two ptrs in size. Addr, followed by len\n\t// https://research.swtch.com/godata\n\n\tmem = cacheMemory(mem, addr, arch.PtrSize()*2)\n\n\tvar strlen int64\n\tvar outaddr uint64\n\tvar err error\n\n\tfor _, field := range typ.StructType.Field {\n\t\tswitch field.Name {\n\t\tcase \"len\":\n\t\t\tstrlen, err = readIntRaw(mem, addr+uint64(field.ByteOffset), int64(arch.PtrSize()))\n\t\t\tif err != nil {\n\t\t\t\treturn 0, 0, fmt.Errorf(\"could not read string len %s\", err)\n\t\t\t}\n\t\t\tif strlen < 0 {\n\t\t\t\treturn 0, 0, fmt.Errorf(\"invalid length: %d\", strlen)\n\t\t\t}\n\t\tcase \"str\":\n\t\t\toutaddr, err = readUintRaw(mem, addr+uint64(field.ByteOffset), int64(arch.PtrSize()))\n\t\t\tif err != nil {\n\t\t\t\treturn 0, 0, fmt.Errorf(\"could not read string pointer %s\", err)\n\t\t\t}\n\t\t\tif addr == 0 {\n\t\t\t\treturn 0, 0, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn outaddr, strlen, nil\n}\n","sourceCodeStart":1521,"sourceCodeEnd":1557,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L1521-L1557","documentation":"While reading a Go string header (the `stringStructDWARF` layout), Delve could not read the `len` field from target memory via `readIntRaw`. The underlying memory-read error is embedded in the message. Without the length, the string value cannot be loaded.","triggerScenarios":"Evaluating any string variable or string field when the read of the `len` word at `addr+ByteOffset` fails; e.g. the string header address is invalid or the memory region is inaccessible.","commonSituations":"Inspecting strings in core dumps where the containing page was not captured; reading strings through a partially-connected remote session; evaluating variables whose addresses come from stale/unreadable stack frames.","solutions":["Read the embedded cause (%s) to see the actual memory error.","Re-evaluate the variable once the target is fully stopped and live.","For core dumps, ensure the memory containing the string header was dumped.","Verify the variable address is valid by printing the enclosing struct."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// (dlv) print str                 // see if the header itself is readable\n// (dlv) print uintptr(str.str)    // verify data pointer","typeGuard":null,"tryCatchPattern":"// Client-side: retry evaluation once the target is fully stopped\nif strings.Contains(err.Error(), \"could not read string len\") {\n    time.Sleep(50 * time.Millisecond)\n    return evalVariable(expr) // retry after state settles\n}","preventionTips":["Ensure the target is stopped before evaluating string variables.","Use core dumps that capture the memory holding the string headers.","Verify enclosing structs print correctly before drilling into string fields."],"tags":["debugger","go","string","memory-read"],"backgroundTag":"string-header-unreadable","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}