go-delve/delve · error

internal error, could not interpret return value of mallocgc

Error message

internal error, could not interpret return value of mallocgc call

What it means

When a string literal must be allocated during a call, Delve injects a call to runtime.mallocgc and then reads back the returned pointer. This internal error means mallocgc's return value did not have the expected shape (exactly one child) so Delve could not extract the new allocation's address. It signals a mismatch between Delve's expectations and the Go runtime's behavior/version, not user input.

Source

Thrown at pkg/proc/fncall.go:1117

func (scope *EvalScope) convertAllocToString(stack *evalStack) {
	mallocv := stack.pop()
	v := stack.pop()

	mallocv.loadValue(LoadFullValue())

	if mallocv.Unreadable != nil {
		stack.err = mallocv.Unreadable
		return
	}

	if mallocv.DwarfType.String() != "*void" {
		stack.err = fmt.Errorf("unexpected return type for mallocgc call: %v", mallocv.DwarfType.String())
		return
	}

	if len(mallocv.Children) != 1 {
		stack.err = errors.New("internal error, could not interpret return value of mallocgc call")
		return
	}

	v.Base = mallocv.Children[0].Addr
	_, stack.err = scope.Mem.WriteMemory(v.Base, []byte(constant.StringVal(v.Value)))
	stack.push(v)
}

func isCallInjectionStop(t *Target, thread Thread, loc *Location) bool {
	if loc.Fn == nil {
		return false
	}
	if !strings.HasPrefix(loc.Fn.Name, debugCallFunctionNamePrefix1) && !strings.HasPrefix(loc.Fn.Name, debugCallFunctionNamePrefix2) {
		return false
	}
	if loc.PC == loc.Fn.Entry {
		// call injection just started, did not make any progress before being interrupted by a concurrent breakpoint.
		return false

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Match your Delve version to your Go toolchain version (upgrade or downgrade one of them)
  2. Retry the evaluation after stepping to a clean breakpoint state
  3. Avoid expressions that force string allocation (print parts separately) as a workaround
  4. File a Delve bug with the Go and Delve versions if it reproduces on supported combinations

Example fix

// before
go install github.com/go-delve/delve/cmd/dlv@latest # against older Go
// after: pin a compatible pair
go1.24 + dlv v1.24.x (see Delve compatibility notes)
Defensive patterns

Strategy: retry

Try / catch

err := doStringAllocCall()
if err != nil && strings.Contains(err.Error(), "internal error, could not interpret return value of mallocgc") {
    // retry once on a supported Go/Delve combination; else report versions
}

Prevention

When it happens

Trigger: String allocation during call injection on a Go runtime whose mallocgc return value layout differs from what this Delve expects; corrupted or unreadable return-variable children after mallocgc completes.

Common situations: Running a newer/older Go toolchain than the Delve version supports; debugging binaries stripped of needed DWARF so return values parse incorrectly.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/93a04333636e1f79. Report an issue: GitHub.