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

graphql: fix an issue of nil pointer panic #28416

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Oct 26, 2023

Fix as issue of nil pointer panic

query

{blocks { number }}

response

{
  "errors": [
    {
      "message": "panic occurred: runtime error: invalid memory address or nil pointer dereference",
      "path": [
        "blocks"
      ]
    }
  ],
  "data": null
}

and the stack:

> 2023/10/26 08:25:36 graphql: panic occurred: runtime error: invalid memory address or nil pointer dereference
goroutine 4252 [running]:
github.com/graph-gophers/graphql-go/log.(*DefaultLogger).LogPanic(0x28?, {0x104254960?, 0x140014805a0}, {0x103fdb9a0, 0x104d31bf0})
        github.com/graph-gophers/graphql-go@v1.3.0/log/log.go:21 +0x58
github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2.1()
        github.com/graph-gophers/graphql-go@v1.3.0/internal/exec/exec.go:187 +0x80
panic({0x103fdb9a0?, 0x104d31bf0?})
        runtime/panic.go:914 +0x218
github.com/ethereum/go-ethereum/graphql.(*Resolver).Blocks(0x140014a6210, {0x104254960, 0x14001480630}, {0x0?, 0x0?})
        github.com/ethereum/go-ethereum/graphql/graphql.go:1327 +0x30
reflect.Value.call({0x104159a60?, 0x140014a6210?, 0x1400075ac68?}, {0x10386365d, 0x4}, {0x14001480660, 0x2, 0x103391400?})
        reflect/value.go:596 +0x994
reflect.Value.Call({0x104159a60?, 0x140014a6210?, 0x104253590?}, {0x14001480660?, 0x10422b220?, 0x1b?})
        reflect/value.go:380 +0x94
github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection.func2(0x1400064c638?, {0x104254960?, 0x140014805a0?}, 0x14000b760c0, 0x14001490140, 0x140009a3eb0, {0x104254960?, 0x14001480630})
        github.com/graph-gophers/graphql-go@v1.3.0/internal/exec/exec.go:211 +0x380
github.com/graph-gophers/graphql-go/internal/exec.execFieldSelection({0x104254960, 0x140014805a0}, 0x1400101c100, 0x0?, 0x14001490140, 0x0?, 0x1)
        github.com/graph-gophers/graphql-go@v1.3.0/internal/exec/exec.go:231 +0x118
github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections.func1(0x14001490140)
        github.com/graph-gophers/graphql-go@v1.3.0/internal/exec/exec.go:81 +0x178
created by github.com/graph-gophers/graphql-go/internal/exec.(*Request).execSelections in goroutine 4250
        github.com/graph-gophers/graphql-go@v1.3.0/internal/exec/exec.go:77 +0x140

context: context.Background.WithValue(type *http.contextKey, val <not Stringer>).WithValue(type *http.contextKey, val 127.0.0.1:8545).WithCancel.WithCancel.WithCancel.WithValue(type opentracing.contextKey, val <not Stringer>)

@s1na PTAL

Signed-off-by: jsvisa <delweng@gmail.com>
@jsvisa jsvisa requested a review from s1na as a code owner October 26, 2023 00:26
@s1na
Copy link
Contributor

s1na commented Oct 26, 2023

The default values that make sense would be 0 or like last finalized block. But 0 can be too long a range and finalized is rather arbitrary. I agree best to return an error. We should make a list of all these errors to standardize.

Copy link
Contributor

@s1na s1na left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@s1na s1na merged commit abe3fca into ethereum:master Oct 26, 2023
2 checks passed
@jsvisa jsvisa deleted the graphql-blocks-missing-from branch October 26, 2023 12:23
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Signed-off-by: jsvisa <delweng@gmail.com>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Dergarcon pushed a commit to specialmechanisms/mev-geth-0x2mev that referenced this pull request Jan 31, 2024
Signed-off-by: jsvisa <delweng@gmail.com>
colinlyguo pushed a commit to scroll-tech/go-ethereum that referenced this pull request Oct 31, 2024
Signed-off-by: jsvisa <delweng@gmail.com>
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.

3 participants