You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
```c++
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.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0 commit comments