iotaledger / iota-core

Apache License 2.0
60 stars 12 forks source link

Nil pointer in CommitmentVerifier during chain switching #619

Closed karimodm closed 9 months ago

karimodm commented 10 months ago
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xef022a]

goroutine 143 [running]:
github.com/iotaledger/iota-core/pkg/protocol/engine.(*Engine).APIForSlot(...)
    /scratch/pkg/protocol/engine/engine.go:313
github.com/iotaledger/iota-core/pkg/protocol.newCommitmentVerifier(0x0, 0xc000aa4900)
    /scratch/pkg/protocol/commitment_verifier.go:32 +0x2a
github.com/iotaledger/iota-core/pkg/protocol.(*AttestationsProtocol).setupCommitmentVerifier.func1()
    /scratch/pkg/protocol/protocol_attestations.go:236 +0x52
github.com/iotaledger/hive.go/ds/shrinkingmap.(*ShrinkingMap[...]).GetOrCreate(0x2e03340, {0xfb, 0x8f, 0x8e, 0x2b, 0xfd, 0x9e, 0xfa, 0x97, 0x1a, ...}, ...)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/shrinkingmap/shrinkingmap.go:119 +0x176
github.com/iotaledger/iota-core/pkg/protocol.(*AttestationsProtocol).setupCommitmentVerifier(0xc000371800, 0xc0004d2c60)
    /scratch/pkg/protocol/protocol_attestations.go:235 +0x20a
github.com/iotaledger/iota-core/pkg/protocol.newAttestationsProtocol.func1.1.1(0x20?)
    /scratch/pkg/protocol/protocol_attestations.go:52 +0x1b
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0x1e
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:255 +0x3f
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1(0x1?, 0xc001232600)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0xb0
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1(0x3b?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:261 +0xc4
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2debb60?, 0xc00059af90)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x122
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Set(...)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:44
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).ToggleValue(0x2debb60, 0x78)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:100 +0x5d
github.com/iotaledger/iota-core/pkg/protocol.(*Chains).initChainSwitching.func2(0xc0012325c0?)
    /scratch/pkg/protocol/chains.go:113 +0x27
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0x1e
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:255 +0x3f
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1(0xc0004d2c60?, 0xc0012325a0)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0xad
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1(0xb43438?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:261 +0xc4
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2debc80?, 0x1)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/iota-core/pkg/protocol.(*Chains).initHeaviestCandidateTracking.func1(0xc000f93a70?, 0x41b)
    /scratch/pkg/protocol/chains.go:147 +0xe2
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2deb920?, 0x1)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Set(0x1?, 0xc00059b250?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:44 +0x45
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).InheritFrom.func1(0xc00059b2b0?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:84 +0x25
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2deb920?, 0xc00059b360)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/hive.go/ds/reactive.NewDerivedVariable[...].func1.1(0xc000e47540?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable.go:119 +0xa9
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2deb800?, 0xc001abdea8)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Set(...)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:44
github.com/iotaledger/iota-core/pkg/protocol.(*Chain).addCommitment(0xc0004d2c60, 0xc000e47540)
    /scratch/pkg/protocol/chain.go:312 +0x57
github.com/iotaledger/iota-core/pkg/protocol.(*Commitment).initDerivedProperties.func2(0xc001232520?)
    /scratch/pkg/protocol/commitment.go:194 +0x25
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0x1e
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:255 +0x3f
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1(0xc0004d2c60?, 0xc001232500)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0xad
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1(0xc0012324c0?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:261 +0xc4
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2debc80?, 0xc0012324c0)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Set(0x2dfe380?, 0xf1bd01?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:44 +0x45
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).InheritFrom.func1(0xc000d375c4?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:84 +0x25
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdate(0x2dea880, 0xc001234078, {0xc000d375c5, 0x1?, 0xc000100000})
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:200 +0x18b
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).InheritFrom(...)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:83
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).DeriveValueFrom(0x2dd6e90, {0x2dd94c0?, 0xc001abd230?})
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:93 +0xcf
github.com/iotaledger/iota-core/pkg/protocol.(*Commitment).deriveChain(0xc000e47540, 0xc0005b9e00)
    /scratch/pkg/protocol/commitment.go:226 +0xf1
github.com/iotaledger/iota-core/pkg/protocol.(*Commitment).initDerivedProperties.func1(0xc0005b9e00)
    /scratch/pkg/protocol/commitment.go:175 +0x79
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0x1e
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1.1()
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:255 +0x3f
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).WithValue.func1(0xc0005b9e00?, 0xc00117ec40)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:171 +0xad
github.com/iotaledger/hive.go/ds/reactive.(*readableVariable[...]).OnUpdateWithContext.func1(0xc00059bad8?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:261 +0xc4
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Compute(0x2deb800?, 0xef33d0)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:56 +0x134
github.com/iotaledger/hive.go/ds/reactive.(*variable[...]).Set(...)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/reactive/variable_impl.go:44
github.com/iotaledger/iota-core/pkg/protocol.(*Commitments).initCommitment.func1(0x7f41eddd6650?)
    /scratch/pkg/protocol/commitments.go:232 +0x26
github.com/iotaledger/iota-core/pkg/core/promise.(*Promise[...]).OnSuccess(0x2ddd8c0, 0xc001ae2950)
    /scratch/pkg/core/promise/promise.go:115 +0x94
github.com/iotaledger/iota-core/pkg/protocol.(*Commitments).initCommitment(0xc0004003c0, 0xc000e47540, {0x2ddcf10, 0xc000c95700})
    /scratch/pkg/protocol/commitments.go:231 +0x1c5
github.com/iotaledger/iota-core/pkg/protocol.(*Commitments).cachedRequest.func1(0xc001903fe0?)
    /scratch/pkg/protocol/commitments.go:208 +0x25
github.com/iotaledger/iota-core/pkg/core/promise.(*Promise[...]).Resolve.func1(0xc001903f60?)
    /scratch/pkg/core/promise/promise.go:62 +0x1a
github.com/iotaledger/hive.go/ds/orderedmap.(*OrderedMap[...]).ForEach(0xc000f93620, 0xc00059bd08?)
    /go/pkg/mod/github.com/iotaledger/hive.go/ds@v0.0.0-20231206114953-6a65a82e30ad/orderedmap/orderedmap.go:130 +0xc3
github.com/iotaledger/iota-core/pkg/core/promise.(*Promise[...]).Resolve(0x2ddd8c0, 0xc000e47540)
    /scratch/pkg/core/promise/promise.go:61 +0xd4
github.com/iotaledger/iota-core/pkg/protocol.(*Commitments).publishCommitmentModel(0x2?, 0xc0010a6300)
    /scratch/pkg/protocol/commitments.go:176 +0x229
github.com/iotaledger/iota-core/pkg/protocol.(*CommitmentsProtocol).ProcessResponse-fm.(*CommitmentsProtocol).ProcessResponse.func1()
    /scratch/pkg/protocol/protocol_commitments.go:84 +0x2c7
github.com/iotaledger/hive.go/runtime/workerpool.(*Task).run(0xc001abc120)
    /go/pkg/mod/github.com/iotaledger/hive.go/runtime@v0.0.0-20231206114953-6a65a82e30ad/workerpool/task.go:48 +0x72
github.com/iotaledger/hive.go/runtime/workerpool.(*WorkerPool).workerReadLoop(0xc00028da40)
    /go/pkg/mod/github.com/iotaledger/hive.go/runtime@v0.0.0-20231206114953-6a65a82e30ad/workerpool/workerpool.go:190 +0x25
github.com/iotaledger/hive.go/runtime/workerpool.(*WorkerPool).worker(0xc00028da40)
    /go/pkg/mod/github.com/iotaledger/hive.go/runtime@v0.0.0-20231206114953-6a65a82e30ad/workerpool/workerpool.go:170 +0x50
created by github.com/iotaledger/hive.go/runtime/workerpool.(*WorkerPool).startWorkers in goroutine 1
    /go/pkg/mod/github.com/iotaledger/hive.go/runtime@v0.0.0-20231206114953-6a65a82e30ad/workerpool/workerpool.go:162 +0x25
piotrm50 commented 9 months ago

Didn't show up after merging the Reactive Chain Manager which changed a lot of the code related to the error.