erigontech / erigontech/silkworm

datastore: EliasFanoList32 spans invalid after move

Open
#2,882 0 comments 0 reactions 0 assignees View on GitHub
snapshots
Dominant language
C++
Stars
318
Forks
84
PR merge metrics
No merged PRs in 30d

Description

EliasFanoList32 potentially owns the data inside a data_holder_ property (as Bytes inside BytesOrByteView).
EliasFanoList32 contains spans that point somewhere inside that data: lower_bits_, upper_bits_, jump_.
These spans are initialized in derive_fields() method.
If EliasFanoList32 is moved, the spans potentially become dangling pointers, and accessing the list values might crash.

Potential solutions:
1. Implement move constructor/assignment and call derive_fields() there to reassign spans. This has performance impact.
2. Instead of using std::span, store an (offset, size) pair relative to the data_holder_ for each span (lower_bits_, upper_bits_, jump_). The spans can be created on demand using (offset, size). See data() method.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.