go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

eth/tracers: pad memory slice on OOB case

Open s1na opened this issue 2 years ago • 4 comments

Fixes https://github.com/ethereum/go-ethereum/issues/25169

s1na avatar Jun 30 '22 15:06 s1na

A constant padding limit will hide factual OOB mistakes. Can we save the post-op memory size in ScopeContext?

yierx avatar Jul 04 '22 13:07 yierx

Can we save the post-op memory size in ScopeContext?

@yierx not really, we don't have the post-op memory size by the time CaptureState is called. Given that EVM memory reads behave similarly I imagine this to be ok.

s1na avatar Jul 06 '22 08:07 s1na

Just curious, instead of padding, we could just return a smaller slice than requested. How come it was decided to zero-pad instead?

holiman avatar Aug 10 '22 07:08 holiman

No idea why, but appveyor 32-bit build says

t=2022-08-31T06:34:34+0000 lvl=trce msg="Promoted queued transactions"          count=0
t=2022-08-31T06:34:34+0000 lvl=info msg="Transaction pool stopped"
runtime: out of memory: cannot allocate 4194304-byte block (1713668096 in use)
fatal error: out of memory
goroutine 48120 [running]:
runtime.throw({0x17832dd, 0xd})
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/runtime/panic.go:992 +0x64 fp=0x2fc0fdd8 sp=0x2fc0fdc4 pc=0x11990a4
runtime.(*mcache).allocLarge(0x200088, 0x50000, 0x1)
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/runtime/mcache.go:215 +0x1e9 fp=0x2fc0fe00 sp=0x2fc0fdd8 pc=0x1175869
runtime.mallocgc(0x50000, 0x0, 0x0)
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/runtime/malloc.go:1096 +0x446 fp=0x2fc0fe48 sp=0x2fc0fe00 pc=0x116c906
github.com/ethereum/go-ethereum/common.CopyBytes(...)
	C:/projects/go-ethereum/common/bytes.go:44
github.com/ethereum/go-ethereum/core/types.(*LegacyTx).copy(0x7f322d00)
	C:/projects/go-ethereum/core/types/legacy_tx.go:66 +0x9a fp=0x2fc0ff1c sp=0x2fc0fe48 pc=0x135f53a
github.com/ethereum/go-ethereum/core/types.NewTx({0x18c11c8, 0x7f322d00})
	C:/projects/go-ethereum/core/types/transaction.go:64 +0x3b fp=0x2fc0ff34 sp=0x2fc0ff1c pc=0x136265b
github.com/ethereum/go-ethereum/core/types.NewTransaction(...)
	C:/projects/go-ethereum/core/types/legacy_tx.go:39
github.com/ethereum/go-ethereum/core.pricedDataTransaction(0x0, 0x0, 0x7f301760, 0x7f339f38, 0x50000)
	C:/projects/go-ethereum/core/tx_pool_test.go:96 +0x17e fp=0x2fc0ff60 sp=0x2fc0ff34 pc=0x1645c3e
github.com/ethereum/go-ethereum/core.TestTransactionSlotCount(0x39f3def0)
	C:/projects/go-ethereum/core/tx_pool_test.go:2416 +0x1cf fp=0x2fc0ff9c sp=0x2fc0ff60 pc=0x1662d5f
testing.tRunner(0x39f3def0, 0x18037d0)
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/testing/testing.go:1439 +0x113 fp=0x2fc0ffe4 sp=0x2fc0ff9c pc=0x1255c53
testing.(*T).Run.func1()
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/testing/testing.go:1486 +0x2e fp=0x2fc0fff0 sp=0x2fc0ffe4 pc=0x1256a4e
runtime.goexit()
	C:/Users/appveyor/AppData/Local/geth-go-1.18.5-windows-amd64/go/src/runtime/asm_386.s:1326 +0x1 fp=0x2fc0fff4 sp=0x2fc0fff0 pc=0x11c8651

holiman avatar Aug 31 '22 10:08 holiman