Skip to content

Repeated call to pebbleIterator.Release accesses memory returned to sync.Pool #28565

Closed
OffchainLabs/go-ethereum
#273
@magicxyyz

Description

@magicxyyz

System information

Commit hash : c8a2202 (current master)

Expected behaviour

pebbleIterator release should always succeed and can be called multiple times without causing error.

// Release releases associated resources. Release should always succeed and can
// be called multiple times without causing error.
func (iter *pebbleIterator) Release() { iter.iter.Close() }

Actual behaviour

Calling pebbleIterator.Release more then once will result in calling github.com/cockroachdb/pebble.Iterator.Close more then once, what is an invalid operation, as "it is not valid to call any method, including Close, after the iterator has been closed".

https://github.com/cockroachdb/pebble/blob/aa077af625936fb6b52d8efdd1a8bcf7070a1509/iterator.go#L2225-L2229

Second call to pebble.Iterator.Close will result in access to memory that was returned to sync.Pool and may have already been acquired by another iterator in another goroutine.

https://github.com/cockroachdb/pebble/blob/aa077af625936fb6b52d8efdd1a8bcf7070a1509/iterator.go#L2327-L2327

https://github.com/cockroachdb/pebble/blob/aa077af625936fb6b52d8efdd1a8bcf7070a1509/db.go#L1045-L1049

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions