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

core/vm: evm fix panic #23047

Merged
merged 2 commits into from
Jun 16, 2021
Merged

core/vm: evm fix panic #23047

merged 2 commits into from
Jun 16, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Jun 15, 2021

Without this PR:

[user@work evm]$ ./evm --json --code 0x48 run
{"pc":0,"op":72,"gas":"0x2540be400","gasCost":"0x2","memory":"0x","memSize":0,"stack":[],"returnStack":null,"returnData":"0x","depth":1,"refund":0,"opName":"BASEFEE","error":""}
{"output":"","gasUsed":"0x0","time":277726}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x608dcb]

goroutine 1 [running]:
math/big.(*Int).Bits(...)
        /usr/local/go/src/math/big/int.go:87
github.com/holiman/uint256.(*Int).SetFromBig(0xc00018b670, 0x0, 0x0)
        /home/user/go/pkg/mod/github.com/holiman/uint256@v1.2.0/conversion.go:102 +0x4b
github.com/holiman/uint256.FromBig(...)
        /home/user/go/pkg/mod/github.com/holiman/uint256@v1.2.0/conversion.go:50
github.com/ethereum/go-ethereum/core/vm.opBaseFee(0xc0000368f0, 0xc0006c0900, 0xc00000e4e0, 0x42af48, 0x2540be400, 0x2, 0xc00000e4e0, 0x0)
        /home/user/go/src/github.com/ethereum/go-ethereum/core/vm/eips.go:173 +0x5e
github.com/ethereum/go-ethereum/core/vm.(*EVMInterpreter).Run(0xc0006c0900, 0xc0000dc180, 0x12d9f40, 0x0, 0x0, 0xc00003a300, 0x0, 0x0, 0x0, 0x0, ...)
        /home/user/go/src/github.com/ethereum/go-ethereum/core/vm/interpreter.go:286 +0x534
github.com/ethereum/go-ethereum/core/vm.run(0xc000697500, 0xc0000dc180, 0x12d9f40, 0x0, 0x0, 0xe41ccf56fa3b6a00, 0x0, 0x0, 0x0, 0x0, ...)
        /home/user/go/src/github.com/ethereum/go-ethereum/core/vm/evm.go:73 +0x224
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call(0xc000697500, 0xdc05a0, 0xc0006bc000, 0x0, 0x6563657200000000, 0xc072657669, 0x12d9f40, 0x0, 0x0, 0x2540be400, ...)
        /home/user/go/src/github.com/ethereum/go-ethereum/core/vm/evm.go:259 +0x6cb
github.com/ethereum/go-ethereum/core/vm/runtime.Call(0x0, 0x6563657200000000, 0x72657669, 0x12d9f40, 0x0, 0x0, 0xc0006c0000, 0xc8926ae909, 0xc614285, 0xc614285012a7260, ...)
        /home/user/go/src/github.com/ethereum/go-ethereum/core/vm/runtime/runtime.go:179 +0x258
main.runCmd.func2(0xc02a61a48c614285, 0x3532582, 0x12a67e0, 0x0, 0x0, 0x0)
        /home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/runner.go:263 +0x7d
main.timedExec(0xc00069c100, 0xc000091900, 0x5, 0x72657600, 0xc0000368a8, 0x1, 0x8, 0xc0000f64e0, 0x0, 0x0, ...)
        /home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/runner.go:96 +0x464
main.runCmd(0xc00069c160, 0x0, 0x0)
        /home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/runner.go:268 +0xfc5
gopkg.in/urfave/cli%2ev1.HandleAction(0xba3fc0, 0xd14d28, 0xc00069c160, 0xc000092d00, 0x0)
        /home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:490 +0x82
gopkg.in/urfave/cli%2ev1.Command.Run(0xcabe78, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcbeeae, 0x18, 0x0, ...)
        /home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/command.go:210 +0x9bb
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc0000f61a0, 0xc000138000, 0x5, 0x5, 0x0, 0x0)
        /home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:255 +0x768
main.main()
        /home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/main.go:201 +0x55

With this PR:

[user@work evm]$ ./evm --json --code 0x48 run
{"pc":0,"op":72,"gas":"0x2540be400","gasCost":"0x2","memory":"0x","memSize":0,"stack":[],"returnStack":null,"returnData":"0x","depth":1,"refund":0,"opName":"BASEFEE","error":""}
{"pc":1,"op":0,"gas":"0x2540be3fe","gasCost":"0x0","memory":"0x","memSize":0,"stack":["0x0"],"returnStack":null,"returnData":"0x","depth":1,"refund":0,"opName":"STOP","error":""}
{"output":"","gasUsed":"0x2","time":269783}

@holiman
Copy link
Contributor Author

holiman commented Jun 15, 2021

This was part of #22901

@@ -93,6 +94,9 @@ func setDefaults(cfg *Config) {
return common.BytesToHash(crypto.Keccak256([]byte(new(big.Int).SetUint64(n).String())))
}
}
if cfg.BaseFee == nil {
cfg.BaseFee = new(big.Int)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be params.InitialBaseFee? Also, shouldn't we aso set LondonBlock in the chain confg above?

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

LGTM
edit, sorry was a bit too quick with that, will be more thorough in the future

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

@karalabe karalabe added this to the 1.10.4 milestone Jun 16, 2021
@karalabe karalabe merged commit 080b6eb into ethereum:master Jun 16, 2021
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
* core/vm: evm fix panic

* core/vm/runtime: default to params.initialbasefee
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 19, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 21, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 22, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 23, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 26, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Sep 27, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 9, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 17, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 18, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 25, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 29, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 30, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Oct 31, 2024
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 1, 2024
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Nov 13, 2024
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