Skip to content

Fix nil pointer dereference in TraceBlockByHash#162

Open
jcbucb wants to merge 1 commit intocoinbase:masterfrom
jcbucb:fix/nil-pointer-trace-block-by-hash
Open

Fix nil pointer dereference in TraceBlockByHash#162
jcbucb wants to merge 1 commit intocoinbase:masterfrom
jcbucb:fix/nil-pointer-trace-block-by-hash

Conversation

@jcbucb
Copy link
Copy Markdown

@jcbucb jcbucb commented Apr 14, 2026

Summary

  • Adds nil check for tx.Result before accessing tx.Result.Type in TraceBlockByHash
  • Prevents panic when debug_traceBlockByHash returns a trace entry with a null result

Root Cause

In TraceBlockByHash, the code checks tx.Result.Type == "" (line 451) without first checking if tx.Result is nil. The Result field is a pointer (*Call), so when the RPC returns {"result": null} for a trace entry, accessing .Type on a nil pointer causes a panic.

// ❌ Before
if tx.Result.Type == "" {  // panics if tx.Result is nil

// ✅ After
if tx.Result == nil || tx.Result.Type == "" {

Context

This panic is being observed in production on Sei EVM (rosetta-seievm) during /block requests. The stack trace:

github.com/coinbase/rosetta-geth-sdk/client.(*SDKClient).TraceBlockByHash(...)
    client/client.go:452

Test plan

  • Deploy downstream consumers to dev and monitor for panics disappearing

🤖 Generated with Claude Code

Add nil check for tx.Result before accessing tx.Result.Type to
prevent panic when debug_traceBlockByHash returns a trace entry
with a null result.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cb-heimdall
Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants