Skip to content

Conversation

@ahuber21
Copy link
Contributor

@ahuber21 ahuber21 commented Dec 9, 2025

The previous code always performed a full width load on the provided data. In ragged-epilogue scenarios, where we request a masked load, this resulted in SEGV errors in certain runs with address sanitizer.

    if (i < count.size()) {
        auto mask = create_mask<simd_width>(count);
        s0 = op.accumulate(mask, s0, op.load_a(mask, a + i), op.load_b(mask, b + i));
    }

Why wasn't this caught sooner?

The OS only triggers a segmentation fault if a read accesses an unmapped memory page. Since memory protection (typically) operates at a 4KB page granularity, reading past the end of a buffer is "safe" from the OS's perspective unless the overflow happens to cross exactly into an unmapped page.

Why is ASan catching it sporadically?

Since our underlying object storage is std::vector, ASan detection requires two specific conditions to align:

  • No Spare Capacity: The vector's size() must equal its capacity(). If there is spare capacity, the unsafe load simply reads valid (though uninitialized) memory owned by the vector.
  • Alignment & Redzones: The underlying heap allocation must be sized and aligned such that the full-width SIMD read (e.g., 32 bytes) actually crosses the allocation boundary into the ASan redzone. If the allocator adds padding for alignment, the read might land in that valid padding instead.

@ahuber21 ahuber21 requested a review from ibhati as a code owner December 9, 2025 10:14
@ahuber21 ahuber21 removed the request for review from homksei December 9, 2025 15:09
@ahuber21 ahuber21 requested a review from ibhati December 10, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants