Skip to content

datastore: EliasFanoList32 spans invalid after move #2882

@battlmonstr

Description

@battlmonstr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    snapshotsFramework for BitTorrent-based snapshots

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions