Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to print variable in previous stack frame on macos #3505

Open
derekparker opened this issue Sep 19, 2023 · 3 comments
Open

Unable to print variable in previous stack frame on macos #3505

derekparker opened this issue Sep 19, 2023 · 3 comments
Labels

Comments

@derekparker
Copy link
Member

derekparker commented Sep 19, 2023

  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.

@derekparker derekparker changed the title Unable to print variable in previous stack frame Unable to print variable in previous stack frame on macos Sep 19, 2023
@AlekSi
Copy link

AlekSi commented Nov 15, 2023

Can confirm with go version go1.21.4 darwin/arm64

@aarzilli
Copy link
Member

I wonder if this is still the case after d186e14

@pradyunsg
Copy link

I can confirm I still see this.

❯ go version                                         
go version go1.22.2 darwin/arm64
❯ ~/go/bin/dlv version  
Delve Debugger
Version: 1.22.1
Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants