-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Description
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x8b2abf]
goroutine 55 [running]:
github.com/gcash/bchd/database/ffldb.rollbackOnPanic(0xc001244c80)
/home/chris/workspace/bchd/database/ffldb/db.go:1903 +0x77
panic(0xc5e180, 0x15ae830)
/usr/lib/go-1.14/src/runtime/panic.go:969 +0x166
github.com/gcash/bchd/database/ffldb.(*blockStore).writeData(0xc00012a320, 0xc00da3b3a0, 0x4, 0x4, 0xd786aa, 0x11, 0x0, 0xd27660)
/home/chris/workspace/bchd/database/ffldb/blockio.go:387 +0x4f
github.com/gcash/bchd/database/ffldb.(*blockStore).writeBlock(0xc00012a320, 0xc00f7d2000, 0xba747, 0xba747, 0x9e026, 0x0, 0x0, 0x0, 0x0)
/home/chris/workspace/bchd/database/ffldb/blockio.go:433 +0x10a
github.com/gcash/bchd/database/ffldb.(*transaction).writePendingAndCommit(0xc001244c80, 0xc001244c80, 0xc0089d8b00)
/home/chris/workspace/bchd/database/ffldb/db.go:1685 +0x41c
github.com/gcash/bchd/database/ffldb.(*transaction).Commit(0xc001244c80, 0x0, 0x0)
/home/chris/workspace/bchd/database/ffldb/db.go:1758 +0x9d
github.com/gcash/bchd/database/ffldb.(*db).Update(0xc00007e000, 0xc0000a4ec0, 0x0, 0x0)
/home/chris/workspace/bchd/database/ffldb/db.go:1970 +0x100
github.com/gcash/bchd/blockchain.(*BlockChain).maybeAcceptBlock(0xc000141c00, 0xc00cef3ae0, 0xc00d91a584, 0xc00deca9a0, 0x4, 0x0, 0x0, 0xca2eab670e0973db)
/home/chris/workspace/bchd/blockchain/accept.go:55 +0x113
github.com/gcash/bchd/blockchain.(*BlockChain).ProcessBlock(0xc000141c00, 0xc00cef3ae0, 0xc000000004, 0xc002910000, 0x0, 0x0)
/home/chris/workspace/bchd/blockchain/process.go:218 +0x27d
github.com/gcash/bchd/netsync.(*SyncManager).handleBlockMsg(0xc00029a300, 0xc0072cd780)
/home/chris/workspace/bchd/netsync/manager.go:787 +0x227
github.com/gcash/bchd/netsync.(*SyncManager).blockHandler(0xc00029a300)
/home/chris/workspace/bchd/netsync/manager.go:1436 +0x703
created by github.com/gcash/bchd/netsync.(*SyncManager).Start
/home/chris/workspace/bchd/netsync/manager.go:1696 +0xd7
This panic stems from this line trying to write the height of the final block when moving to a new file. The reason for the panic is because curFile.file
is nil.
https://github.com/gcash/bchd/blob/master/database/ffldb/blockio.go#L433
Later on in this function we have:
// Open the current file if needed. This will typically only be the
// case when moving to the next file to write to or on initial database
// load. However, it might also be the case if rollbacks happened after
// file writes started during a transaction commit.
if wc.curFile.file == nil {
file, err := s.openWriteFileFunc(wc.curFileNum)
if err != nil {
return blockLocation{}, err
}
wc.curFile.file = file
}
It seems it may be possible that it's trying to load curFile.file
before it was set. Possibly an edge case where the first block to be processed on startup is creating a new block file?
Duplicating the above code block right before L433 appears to have got past the error though it's unclear if this is correct code wise.
Metadata
Metadata
Assignees
Labels
No labels