cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.17k stars 3.57k forks source link

Invalid Memory Address or Nil Pointer Dereference #14749

Closed siftequarahmed closed 1 year ago

siftequarahmed commented 1 year ago

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1545c8d]

goroutine 1 [running]: github.com/cosmos/cosmos-sdk/x/upgrade.BeginBlocker({{0x7ffc8dfe5e23, 0x25}, 0xc006fe5a10, {0x2e26728, 0xc0042482c0}, {0x2e4ac58, 0xc0042322e0}, 0xc004247050, {0x2e1fc00, 0xc000f00000}, ...}, ...) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/x/upgrade/abci.go:38 +0x100d github.com/cosmos/cosmos-sdk/x/upgrade.AppModule.BeginBlock(...) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/x/upgrade/module.go:130 github.com/cosmos/cosmos-sdk/types/module.(Manager).BeginBlock(_, {{0x2e3d5c0, 0xc0001b6000}, {0x2e4c940, 0xc03da290c0}, {{0xb, 0x0}, {0xc0e262a6c0, 0xd}, 0x48517e, ...}, ...}, ...) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/types/module/module.go:491 +0x3bb github.com/axelarnetwork/axelar-core/app.(AxelarApp).BeginBlocker(, {{0x2e3d5c0, 0xc0001b6000}, {0x2e4c940, 0xc03da290c0}, {{0xb, 0x0}, {0xc0e262a6c0, 0xd}, 0x48517e, ...}, ...}, ...) /home/runner/work/axelar-core/axelar-core/app/app.go:750 +0x85 github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).BeginBlock(, {{0xc04de91fe0, 0x20, 0x20}, {{0xb, 0x0}, {0xc0e262a6c0, 0xd}, 0x48517e, {0x9cdd9a4, ...}, ...}, ...}) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/baseapp/abci.go:177 +0x97c github.com/tendermint/tendermint/abci/client.(localClient).BeginBlockSync(_, {{0xc04de91fe0, 0x20, 0x20}, {{0xb, 0x0}, {0xc0e262a6c0, 0xd}, 0x48517e, {0x9cdd9a4, ...}, ...}, ...}) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/abci/client/local_client.go:280 +0x118 github.com/tendermint/tendermint/proxy.(appConnConsensus).BeginBlockSync(_, {{0xc04de91fe0, 0x20, 0x20}, {{0xb, 0x0}, {0xc0e262a6c0, 0xd}, 0x48517e, {0x9cdd9a4, ...}, ...}, ...}) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/proxy/appconn.go:81 +0x55 github.com/tendermint/tendermint/state.execBlockOnProxyApp({0x2e3e698?, 0xc08ee90120}, {0x2e445b8, 0xc04dbd9250}, 0xc000eb61e0, {0x2e4bfc8, 0xc01f384498}, 0x48517d?) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/state/execution.go:307 +0x3dd github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(, {{{0xb, 0x0}, {0xc04dbd6f18, 0x7}}, {0xc04dbd6f60, 0xd}, 0x1, 0x48517d, {{0xc04d268100, ...}, ...}, ...}, ...) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/state/execution.go:140 +0x171 github.com/tendermint/tendermint/consensus.(Handshaker).replayBlock(_, {{{0xb, 0x0}, {0xc04dbd6f18, 0x7}}, {0xc04dbd6f60, 0xd}, 0x1, 0x48517d, {{0xc04d268100, ...}, ...}, ...}, ...) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/consensus/replay.go:503 +0x23c github.com/tendermint/tendermint/consensus.(Handshaker).ReplayBlocks(, {{{0xb, 0x0}, {0xc04dbd6f18, 0x7}}, {0xc04dbd6f60, 0xd}, 0x1, 0x48517d, {{0xc04d268100, ...}, ...}, ...}, ...) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/consensus/replay.go:416 +0x7ae github.com/tendermint/tendermint/consensus.(*Handshaker).Handshake(0xc10cecdd48, {0x2e4d438, 0xc02131edd0}) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/consensus/replay.go:268 +0x3c8 github.com/tendermint/tendermint/node.doHandshake({, }, {{{0xb, 0x0}, {0xc04dbd6f18, 0x7}}, {0xc04dbd6f60, 0xd}, 0x1, 0x48517d, ...}, ...) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/node/node.go:330 +0x1b8 github.com/tendermint/tendermint/node.NewNode(0xc0004de280, {0x2e3a0a0, 0xc000eab400}, 0xc00108a410, {0x2e20d60, 0xc0413703a8}, 0x0?, 0x0?, 0xc00108a620, {0x2e3e698, ...}, ...) /home/runner/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/node/node.go:778 +0x597 github.com/cosmos/cosmos-sdk/server.startInProcess(, {{0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x2e42160, 0xc00027ab30}, ...}, ...) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/server/start.go:281 +0x81b github.com/cosmos/cosmos-sdk/server.StartCmd.func2(0xc0004dac80?, {0xc000ea83f0?, 0x1?, 0x3?}) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/server/start.go:129 +0x169 github.com/spf13/cobra.(Command).execute(0xc0004dac80, {0xc000ea8390, 0x3, 0x3}) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:872 +0x694 github.com/spf13/cobra.(Command).ExecuteC(0xc000e92780) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x3b4 github.com/spf13/cobra.(Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918 github.com/spf13/cobra.(Command).ExecuteContext(...) /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:911 github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x1f417b2?, {0xc000610240, 0x1c}) /home/runner/go/pkg/mod/github.com/axelarnetwork/cosmos-sdk@v0.45.10-0.20221026063150-7d9818dc359a/server/cmd/execute.go:36 +0x1eb main.main() /home/runner/work/axelar-core/axelar-core/cmd/axelard/main.go:70 +0x4c5

alexanderbez commented 1 year ago

Looks like the panic comes from here: https://github.com/cosmos/cosmos-sdk/blob/v0.45.10/x/upgrade/abci.go#L38

So this means that the state machine would've panic'd anyway, but that panic was superseded by another panic, namely ctx.ConsensusParams().Version.AppVersion.

alexanderbez commented 1 year ago

This is already fixed in future versions though: https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/x/upgrade/abci.go

I suppose we could fix this on the v0.45.x line, but either way, your process will still panic.

siftequarahmed commented 1 year ago

How can I resolve this error? Do I need to update the cosmos version?

alexanderbez commented 1 year ago

https://github.com/cosmos/cosmos-sdk/blob/v0.45.10/x/upgrade/abci.go#L37

You need to have an upgrade handler set.