go-ethereum/eth/tracers/native
rayoo 8aeef6ae1b eth/tracers: fix data race on interruption reason across tracers
Every tracer that implements Stop/GetResult held a `reason error`
field that is written by Stop (called from the trace-timeout watchdog
goroutine in api.go) and read by GetResult (called by the RPC handler
main goroutine). These accesses were unsynchronized.

Because Go's error is an interface, a racing reader can observe a
torn eface (type pointer and data pointer from different stores),
which is undefined behaviour and can crash the node.

Replace the plain field with atomic.Pointer[error] in:

  - eth/tracers/native/call.go          (callTracer)
  - eth/tracers/native/4byte.go         (fourByteTracer)
  - eth/tracers/native/erc7562.go       (erc7562Tracer)
  - eth/tracers/native/prestate.go      (prestateTracer)
  - eth/tracers/logger/logger.go        (StructLogger)

The flatCallTracer shares callTracer.reason and is fixed transitively.

Add TestTracerStopRace which exercises the concurrent Stop/GetResult
path under -race for each of the five tracers. It fails on master
with the race detector, passes after the fix.
2026-05-09 07:23:36 +08:00
..
4byte.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00
call.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00
call_flat.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00
call_flat_test.go eth/tracers: various fixes (#30540) 2024-10-17 06:51:47 +02:00
erc7562.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00
gen_account_json.go eth/tracers: fix codehash in prestate diffmode (#34675) 2026-04-16 16:51:26 +08:00
gen_callframe_json.go eth/tracers/native: set created address to nil in case of failure (#26779) 2023-03-07 14:39:11 +01:00
gen_callframewithopcodes_json.go eth/tracers/native: add erc7562 tracer (#31006) 2025-05-20 15:38:33 +02:00
gen_flatcallaction_json.go eth/tracers: add native flatCallTracer (aka parity style tracer) (#26377) 2023-02-28 13:54:37 +03:30
gen_flatcallresult_json.go eth/tracers: add native flatCallTracer (aka parity style tracer) (#26377) 2023-02-28 13:54:37 +03:30
keccak256_preimage.go eth/tracers/native: add keccak256preimage tracer (#32569) 2025-09-26 18:05:27 +02:00
keccak256_preimage_test.go eth/tracers/native: add keccak256preimage tracer (#32569) 2025-09-26 18:05:27 +02:00
mux.go cmd/evm: add --opcode.count flag to t8n (#33800) 2026-02-17 20:42:53 +01:00
noop.go eth/tracers: various fixes (#30540) 2024-10-17 06:51:47 +02:00
opcode_counter.go cmd/evm: add --opcode.count flag to t8n (#33800) 2026-02-17 20:42:53 +01:00
prestate.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00
tracer_test.go eth/tracers: fix data race on interruption reason across tracers 2026-05-09 07:23:36 +08:00