Skip to content

Commit 2e3246a

Browse files
committed
channeldb: copy value from boltdb's Get instead of using it directly
This can cause an intermittent panic otherwise if bbolt remaps itself via munmap and mmap. From bbolt's documentation: * Byte slices returned from Bolt are only valid during a transaction. Once the transaction has been committed or rolled back then the memory they point to can be reused by a new page or can be unmapped from virtual memory and you'll see an unexpected fault address panic when accessing it.
1 parent b31640e commit 2e3246a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

channeldb/db.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,11 +1254,13 @@ func (c *ChannelStateDB) GetChannelOpeningState(outPoint []byte) ([]byte, error)
12541254
return ErrChannelNotFound
12551255
}
12561256

1257-
serializedState = bucket.Get(outPoint)
1258-
if serializedState == nil {
1257+
stateBytes := bucket.Get(outPoint)
1258+
if stateBytes == nil {
12591259
return ErrChannelNotFound
12601260
}
12611261

1262+
serializedState = append(serializedState, stateBytes...)
1263+
12621264
return nil
12631265
}, func() {
12641266
serializedState = nil

0 commit comments

Comments
 (0)