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

Add nil checks for type values when processing objects #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pwschuurman
Copy link

@pwschuurman pwschuurman commented Mar 15, 2025

Ran into the below two nil-ptr exceptions.

Culprit seemed to be due to parsing a runtime.itabTableType resource:

     2  40960  81920 [1+8?]runtime.itabTableType

Added two nil-ptr checks to skip if a nil type is encountered.

Core "tmp/core.283046" was generated by "/gce-pd-csi-driver"
Entering interactive mode (type 'help' for commands)
(viewcore) histogram
Error while trying to run command "histogram": runtime error: invalid memory address or nil pointer dereference
Stack: goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/google-golang/src/runtime/debug/stack.go:26 +0x5e
main.capturePanic.func1()
        /workspace/debug/cmd/viewcore/main.go:372 +0x3d
panic({0x9e8b20?, 0xecb700?})
        /usr/lib/google-golang/src/runtime/panic.go:799 +0x132
golang.org/x/debug/internal/gocore.(*Type).field(...)
        /workspace/debug/internal/gocore/type.go:86
golang.org/x/debug/internal/gocore.runtimeItab.Type(...)
        /workspace/debug/internal/gocore/type.go:196
golang.org/x/debug/internal/gocore.(*Process).typeObject(0xc000280000, 0x300b8f0, 0xc001f242a0, {0xb348b0, 0xc000274000}, 0xc00b1e3280)
        /workspace/debug/internal/gocore/type.go:645 +0x155
golang.org/x/debug/internal/gocore.(*Process).doTypeHeap.func2(0x0?)
        /workspace/debug/internal/gocore/type.go:536 +0x91
golang.org/x/debug/internal/gocore.(*Process).ForEachRoot(...)
        /workspace/debug/internal/gocore/object.go:191
golang.org/x/debug/internal/gocore.(*Process).doTypeHeap(0xc000280000)
        /workspace/debug/internal/gocore/type.go:529 +0x1f6
sync.(*Once).doSlow(0x564562?, 0xc00b1e3560?)
        /usr/lib/google-golang/src/sync/once.go:78 +0xab
sync.(*Once).Do(...)
        /usr/lib/google-golang/src/sync/once.go:69
golang.org/x/debug/internal/gocore.(*Process).typeHeap(...)
        /workspace/debug/internal/gocore/type.go:400
golang.org/x/debug/internal/gocore.(*Process).Type(0xc000280000, 0xc000034000)
        /workspace/debug/internal/gocore/object.go:219 +0x4a
main.typeName(0xc000280000, 0xc000034000)
        /workspace/debug/cmd/viewcore/main.go:789 +0x9e
main.runHistogram.func1(0xc000280000?, 0xc000034000, 0x8?)
        /workspace/debug/cmd/viewcore/main.go:484 +0x3a
golang.org/x/debug/internal/gocore.(*Process).ForEachRootPtr.func1(0x0, 0xc00b35afc0?)
        /workspace/debug/internal/gocore/object.go:257 +0x3f
golang.org/x/debug/internal/gocore.walkRootTypePtrs(0xc000280000, 0xc002b15bc0, {0xc00b1e3718, 0x8, 0x8}, 0x0, 0xc007c4c360?, 0xc00b1e3720)
        /workspace/debug/internal/gocore/root.go:163 +0x2ab
golang.org/x/debug/internal/gocore.(*Process).forEachRootPtr(...)
        /workspace/debug/internal/gocore/object.go:269
golang.org/x/debug/internal/gocore.(*Process).ForEachRootPtr(0xc0000fa300?, 0xa6acf5?, 0x3?)
        /workspace/debug/internal/gocore/object.go:254 +0x4b
main.runHistogram(0xc0000fa300?, {0xeffd80?, 0x4?, 0xa6b4df?})
        /workspace/debug/cmd/viewcore/main.go:483 +0x1fb
github.com/spf13/cobra.(*Command).execute(0xed62e0, {0xeffd80, 0x0, 0x0})
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x843
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000ff208)
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.runRoot.func2()
        /workspace/debug/cmd/viewcore/main.go:361 +0x7c
main.capturePanic(0xb32820?)
        /workspace/debug/cmd/viewcore/main.go:376 +0x51
main.runRoot(0xed5760, {0xc00007e880?, 0x4?, 0xa6b4df?})
        /workspace/debug/cmd/viewcore/main.go:358 +0x672
github.com/spf13/cobra.(*Command).execute(0xed5760, {0xc000022120, 0x2, 0x2})
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x843
github.com/spf13/cobra.(*Command).ExecuteC(0xed5760)
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /gopath/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.main()
        /workspace/debug/cmd/viewcore/main.go:244 +0x132
Core "tmp/core.283046" was generated by "/gce-pd-csi-driver"
Entering interactive mode (type 'help' for commands)
(viewcore) histogram
Error while trying to run command "histogram": runtime error: invalid memory address or nil pointer dereference
Stack: goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/google-golang/src/runtime/debug/stack.go:26 +0x5e
main.capturePanic.func1()
        /workspace/debug/cmd/viewcore/main.go:372 +0x3d
panic({0x9e8b20?, 0xecb700?})
        /usr/lib/google-golang/src/runtime/panic.go:799 +0x132
golang.org/x/debug/internal/gocore.(*Process).typeObject(0xc0002ca000, 0x300b8f0, 0xc0033a8300, {0xb348b0, 0xc0002be000}, 0xc00b28d280)
        /workspace/debug/internal/gocore/type.go:648 +0xedb
golang.org/x/debug/internal/gocore.(*Process).doTypeHeap.func2(0x0?)
        /workspace/debug/internal/gocore/type.go:539 +0x91
golang.org/x/debug/internal/gocore.(*Process).ForEachRoot(...)
        /workspace/debug/internal/gocore/object.go:191
golang.org/x/debug/internal/gocore.(*Process).doTypeHeap(0xc0002ca000)
        /workspace/debug/internal/gocore/type.go:532 +0x1f6
sync.(*Once).doSlow(0x564562?, 0xc00b28d560?)
        /usr/lib/google-golang/src/sync/once.go:78 +0xab
sync.(*Once).Do(...)
        /usr/lib/google-golang/src/sync/once.go:69
golang.org/x/debug/internal/gocore.(*Process).typeHeap(...)
        /workspace/debug/internal/gocore/type.go:403
golang.org/x/debug/internal/gocore.(*Process).Type(0xc0002ca000, 0xc000034000)
        /workspace/debug/internal/gocore/object.go:219 +0x4a
main.typeName(0xc0002ca000, 0xc000034000)
        /workspace/debug/cmd/viewcore/main.go:789 +0x9e
main.runHistogram.func1(0xc0002ca000?, 0xc000034000, 0x8?)
        /workspace/debug/cmd/viewcore/main.go:484 +0x3a
golang.org/x/debug/internal/gocore.(*Process).ForEachRootPtr.func1(0x0, 0xc00ac7f440?)
        /workspace/debug/internal/gocore/object.go:257 +0x3f
golang.org/x/debug/internal/gocore.walkRootTypePtrs(0xc0002ca000, 0xc007396480, {0xc00b28d718, 0x8, 0x8}, 0x0, 0xc00826cea0?, 0xc00b28d720)
        /workspace/debug/internal/gocore/root.go:163 +0x2ab
golang.org/x/debug/internal/gocore.(*Process).forEachRootPtr(...)
        /workspace/debug/internal/gocore/object.go:269
golang.org/x/debug/internal/gocore.(*Process).ForEachRootPtr(0xc00017e300?, 0xa6acf5?, 0x3?)
        /workspace/debug/internal/gocore/object.go:254 +0x4b
main.runHistogram(0xc00017e300?, {0xeffd80?, 0x4?, 0xa6b4df?})
        /workspace/debug/cmd/viewcore/main.go:483 +0x1fb
github.com/spf13/cobra.(*Command).execute(0xed62e0, {0xeffd80, 0x0, 0x0})
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x843
github.com/spf13/cobra.(*Command).ExecuteC(0xc000187208)
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.runRoot.func2()
        /workspace/debug/cmd/viewcore/main.go:361 +0x7c
main.capturePanic(0xb32820?)
        /workspace/debug/cmd/viewcore/main.go:376 +0x51
main.runRoot(0xed5760, {0xc00012a860?, 0x4?, 0xa6b4df?})
        /workspace/debug/cmd/viewcore/main.go:358 +0x672
github.com/spf13/cobra.(*Command).execute(0xed5760, {0xc0001300a0, 0x2, 0x2})
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x843
github.com/spf13/cobra.(*Command).ExecuteC(0xed5760)
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
        /gopath/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.main()
        /workspace/debug/cmd/viewcore/main.go:244 +0x132

@gopherbot
Copy link
Contributor

This PR (HEAD: e26381e) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/debug/+/658155.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Peter Schuurman:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Keith Randall:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/658155.
After addressing review feedback, remember to publish your drafts!

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

Successfully merging this pull request may close these issues.

2 participants