#3505·delve

Unable to print variable in previous stack frame on macos

Author: derekparkerCreated Sep 19, 2023Updated Jan 6, 2026
Labelsos/macOS
  1. What version of Delve are you using (dlv version)?
Delve Debugger
Version: 1.21.0
Build: e0b4bfbed31daef19c8b98ff2d9a2e2717c69dd8
  1. What version of Go are you using? (go version)?
go version go1.21.1 darwin/arm64
  1. What operating system and processor architecture are you using?

darwin/arm64

  1. What did you do?

Given the following:

count.go:

package count

import (
	"io"
	"os"
	"strings"
)

// Job is a single job to be performed.
type Job struct {
	url string
}

// ParseURLsFromFile takes a path to a text file containing
// newline delimited URLs and parses them into Job structs
// which can be passed to workers.
func ParseURLsFromFile(path string) ([]*Job, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	b, err := io.ReadAll(f)
	if err != nil {
		return nil, err
	}
	list := string(b)
	urls := strings.Split(list, "\n")

	jobs := make([]*Job, len(urls))
	for _, url := range urls {
		jobs = append(jobs, &Job{url: url})
	}

	return jobs, nil
}

count_test.go:

package count

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestParseURLsFromFile(t *testing.T) {
	jobs, err := ParseURLsFromFile("./testdata/urls.txt")
	assert.Nil(t, err)

	fmt.Printf("%#v\n", jobs)

	// Assert the URLs are parsed in the correct order as we expect.
	assert.Equal(t, "http://google.com", jobs[0].url)
	assert.Equal(t, "http://yahoo.com", jobs[1].url)
	assert.Equal(t, "http://go.dev", jobs[2].url)
}

Run with dlv test and then continue until panic.

Execute frame 7 print jobs

  1. What did you expect to see?

The jobs variable printed with correct values, cap and len information.

  1. What did you see instead?
(dlv) frame 7 print jobs
[]*gc2023/count.Job len: 4302113844, cap: 1374390496832, [
	*{url: (unreadable could not read string at 0x0 due to protocol error E08 during memory read for packet $m0,40)},
	*{url: (unreadable invalid length: -6188504560871472192)},
	*{url: ""},
	*nil,
	*nil,
	*nil,
	*{
		url: "��\x7f���\x00��\x03_��\x03\x1e�j������\x17\x11\x02@���\x00��\x02\x11�!��T�#\x00�\x14\x02\x00����\x17\x00\x00\x00\x00�\v@��c0�...+1374390071228 more",},
	*{url: (unreadable invalid length: -7494520139350540287)},
	*{
		url: "�\v@��c0��\x02\x00T�\x0f\x1c���\x1f��#\x00�@\a@��\x17\x00�\x1b\x00�9\x02�@��\x13\x00�B\x00\x00�\x06\x00\x00\x14\x1b\x00�9�\x1b\x00��\x03\x1f�...+1374390071244 more",},
	*nil,
	*{url: (unreadable could not read string at 0x0 due to protocol error E08 during memory read for packet $m0,40)},
	*nil,
	*nil,
	*nil,
	*nil,
	*{
		url: "��\x7f���\x00��\x03_��\x03\x1e�j������\x17\x11\x02@���\x00��\x02\x11�!��T�#\x00�\x14\x02\x00����\x17\x00\x00\x00\x00�\v@��c0�...+1374390071228 more",},
	*{url: (unreadable invalid length: -6265210773073559551)},
	*{
		url: "�\v@���\n�?\x02\x10�IE\x00T��\fѝ�?��\x02\x00��#\x00�@\a@��[\x00�\x1b\x00�9��\x00�l����\x1f\x019@\x00\x007\x06\x00\x00\x14...+1374390071246 more",},
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*{
		url: "�\v@��c0��\x02\x00T�\x0f\x1c���\x1f��#\x00�@\a@��\x17\x00�\x1b\x00�9\x02�@��\x13\x00�B\x00\x00�\x06\x00\x00\x14\x1b\x00�9�\x1b\x00��\x03\x1f�...+1374390071244 more",},
	*{
		url: "�\v@���\n�?\x02\x10�IE\x00T��\fѝ�?��\x02\x00��#\x00�@\a@��[\x00�\x1b\x00�9��\x00�l����\x1f\x019@\x00\x007\x06\x00\x00\x14...+1374390071246 more",},
	*nil,
	*{url: (unreadable invalid length: -568561867950128503)},
	*{url: ""},
	*{url: (unreadable could not read string at 0xd10ac3f1f9400b90 due to protocol error E08 during memory read for packet $md10ac3f1f9400b90,4...)},
	*{url: ""},
	*{url: (unreadable could not read string at 0x2e676e6974736574 due to protocol error E08 during memory read for packet $m2e676e6974736574,4...)},
	*{url: (unreadable could not read string pointer protocol error E08 during memory read for packet $mf,10)},
	*{url: (unreadable could not read string pointer protocol error E08 during memory read for packet $mc13aa6169370ab58,1...)},
	*{url: (unreadable could not read string pointer protocol error E08 during memory read for packet $m29f5b4,10)},
	*{url: ""},
	*nil,
	*{url: (unreadable could not read string at 0x940007ef due to protocol error E08 during memory read for packet $m940007ef,40)},
	*{url: ""},
	*{
		url: "�\v@���\x03�?\x02\x10�)\x17\x00T��\x05ѝ�?��\x02\x00��#\x00���\x00���\x00���\x12���\v� \x00\x00�\x00�3�a\x02������...+4301068186 more",},
	*{
		url: "�\v@���\x03�?\x02\x10�)\x17\x00T��\x05ѝ�?��\x02\x00��#\x00���\x00���\x00���\x12���\v� \x00\x00�\x00�3�a\x02������...+4301068186 more",},
	*{url: ""},
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*{url: ""},
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	*nil,
	...+4302113780 more
]

Note: in my testing this does not reproduce on linux/amd64.