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

Fix potential deadlock in rawdb.(*freezer).Ancient #22403

Closed
wants to merge 1 commit into from
Closed

Fix potential deadlock in rawdb.(*freezer).Ancient #22403

wants to merge 1 commit into from

Conversation

jotto
Copy link
Contributor

@jotto jotto commented Mar 1, 2021

This appears to fix an issue where geth appears to lock up while running random transactions through the EVM, specifically transactions that make use of the blockhash opcode (typically as a source of randomness).

My limited understanding is:

  • run ethapi.DoCall with tx with blockhash opcode
  • meanwhile, something else is holding a lock on something in the freezer (insert chain?)

@jotto
Copy link
Contributor Author

jotto commented Mar 1, 2021

Disregard, this fix (lock on Ancient lookups) worked longer than my previous attempts, but ultimately failed. Here's what the goroutine in question is doing:

syscall.Syscall6(0x11, 0x10, 0xc084e3878a, 0x6, 0x3d96c98, 0x0, 0x0, 0x6, 0x6, 0x0)
        syscall/asm_linux_amd64.s:43 +0x5
syscall.Pread(0x10, 0xc084e3878a, 0x6, 0x6, 0x3d96c98, 0x6, 0x0, 0x0)
        syscall/zsyscall_linux_amd64.go:1211 +0x72
internal/poll.(*FD).Pread(0xc0001ce720, 0xc084e3878a, 0x6, 0x6, 0x3d96c98, 0x6, 0x0, 0x0)
        internal/poll/fd_unix.go:192 +0xdf
os.(*File).pread(...)
        os/file_posix.go:40
os.(*File).ReadAt(0xc0002945e8, 0xc084e3878a, 0x6, 0x6, 0x3d96c98, 0x6, 0x0, 0x0)
        os/file.go:135 +0x114
github.com/ethereum/go-ethereum/core/rawdb.(*freezerTable).getBounds(0xc00016c2c0, 0xa43cc4, 0x10, 0x119c220, 0xc07ea55620, 0x0)
        github.com/ethereum/go-ethereum/core/rawdb/freezer_table.go:536 +0x105
github.com/ethereum/go-ethereum/core/rawdb.(*freezerTable).Retrieve(0xc00016c2c0, 0xa43cc4, 0x12e1610, 0x7, 0xc000566b18, 0x0, 0x0)
        github.com/ethereum/go-ethereum/core/rawdb/freezer_table.go:575 +0x175
github.com/ethereum/go-ethereum/core/rawdb.(*freezer).Ancient(0xc0001ce5a0, 0x12e1610, 0x7, 0xa43cc4, 0x0, 0x0, 0x0, 0x0, 0x0)
        github.com/ethereum/go-ethereum/core/rawdb/freezer.go:172 +0x125
github.com/ethereum/go-ethereum/core/rawdb.ReadHeaderRLP(0x7f193c0e5e98, 0xc00000e2d0, 0x968a634452a09b79, 0x5ab761ab0cd8f0cd, 0xde041bbec8af6056, 0xbce91dcbf59cba79, 0xa43cc4, 0xc084e38ac8, 0x7cb41d, 0x11577e0)
        github.com/ethereum/go-ethereum/core/rawdb/accessors_chain.go:282 +0xe6
github.com/ethereum/go-ethereum/core/rawdb.ReadHeader(0x7f193c0e5e98, 0xc00000e2d0, 0x968a634452a09b79, 0x5ab761ab0cd8f0cd, 0xde041bbec8af6056, 0xbce91dcbf59cba79, 0xa43cc4, 0xc026a38b40)
        github.com/ethereum/go-ethereum/core/rawdb/accessors_chain.go:311 +0x74
github.com/ethereum/go-ethereum/core.(*HeaderChain).GetHeader(0xc000138090, 0x968a634452a09b79, 0x5ab761ab0cd8f0cd, 0xde041bbec8af6056, 0xbce91dcbf59cba79, 0xa43cc4, 0xc026a38b40)
        github.com/ethereum/go-ethereum/core/headerchain.go:433 +0x125
github.com/ethereum/go-ethereum/core.(*BlockChain).GetHeader(0xc000147900, 0x968a634452a09b79, 0x5ab761ab0cd8f0cd, 0xde041bbec8af6056, 0xbce91dcbf59cba79, 0xa43cc4, 0xc026a38b40)
        github.com/ethereum/go-ethereum/core/blockchain.go:2466 +0x4d
github.com/ethereum/go-ethereum/core.GetHashFn.func1(0xb66c9b, 0x0, 0x0, 0x0, 0x0)
        github.com/ethereum/go-ethereum/core/evm.go:80 +0x177
github.com/ethereum/go-ethereum/core/vm.opBlockhash(0xc079043b18, 0xc068064000, 0xc082125600, 0x0, 0x0, 0x0, 0x0, 0x0)
        github.com/ethereum/go-ethereum/core/vm/instructions.go:448 +0x10f
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run(0xc068064000, 0xc052632b40, 0xc0613ab220, 0x44, 0x44, 0xc091e3ed00, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/ethereum/go-ethereum/core/vm/interpreter.go:287 +0x594
github.com/ethereum/go-ethereum/core/vm.run(0xc066cfd500, 0xc052632b40, 0xc0613ab220, 0x44, 0x44, 0xa83b419d7ee39100, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/ethereum/go-ethereum/core/vm/evm.go:88 +0x224
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call(0xc066cfd500, 0x14e9c80, 0xc090d83b78, 0xcf8b3fe8eeeeced1, 0x15b6027243aded3b, 0x5549f4e, 0xc0613ab220, 0x44, 0x44, 0xa7a0, ...)
        github.com/ethereum/go-ethereum/core/vm/evm.go:260 +0x6cb
github.com/ethereum/go-ethereum/core.(*StateTransition).TransitionDb(0xc06396fc70, 0x150c5b0, 0xc066499860, 0xc079043ae8)
        github.com/ethereum/go-ethereum/core/state_transition.go:260 +0x3e9
github.com/ethereum/go-ethereum/core.ApplyMessage(0xc066cfd500, 0x150c5b0, 0xc066499860, 0xc079043ae8, 0xc066cfd500, 0xc08b7dc300, 0xc066cc0d80)
        github.com/ethereum/go-ethereum/core/state_transition.go:164 +0x57

@jotto
Copy link
Contributor Author

jotto commented Mar 2, 2021

This is looking less like a deadlock, and more like blockhash opcode simply causing slow freezer lookups.

@jotto jotto closed this Mar 3, 2021
@jotto jotto deleted the fix-ancient-deadlock branch March 3, 2021 20:49
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.

None yet

1 participant