Skip to content

Potential SIGSEGV in Replicator #186

@ankur-anand

Description

@ankur-anand

There is a potential test of conditional scenarios where a sigsegv could happen.

  1. Replicator reads a batch of records. The walfs reader returns slices pointing directly to the memory-mapped file.
  2. Replicator sends this batch to the GrpcStreamer via a buffered channel.
  3. Replicator continues its loop, calls reader.Next(), and hits io.EOF.
  4. Replicator immediately calls reader.Close().
  5. This decrements the reference count on the underlying Segment.

If the segment was marked for deletion (e.g., it was rotated and is old), the reference count dropping to zero triggers Segment.cleanup(), which unmaps the memory.
Streamer (running in a separate goroutine) picks up the batch from the channel and tries to marshal the data for gRPC.

The simple fix would be copy the data from the mmap-ed slice into a new slice before adding it to the batch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions