Skip to content

Conversation

@codebytere
Copy link
Member

@codebytere codebytere commented Jul 10, 2025

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6703757

The above CL enabled array bounds sanitization for Electron and therefore Node.js, which triggered a crash in parallel/test-buffer-indexof.js. Upon a bit more investigation, some Boyer-Moore related functions function were using biased pointer arithmetic to create array pointers that point outside the actual array bounds.

When start_ is large this creates pointers far outside the valid memory range. The sanitizer detects that we're creating and dereferencing pointers outside array boundaries, even though the final memory access happens to land in valid memory.

This changes the functions to use bounds-safe array indexing.

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6703757

The above CL enabled array bounds sanitization for Electron and therefore Node.js, which triggered
a crash in parallel/test-buffer-indexof.js. Upon a bit more investigation, some Boyer-Moore related functions
function were using biased pointer arithmetic to create array pointers that point outside the actual array bounds.

When start_ is large this creates pointers far outside the valid memory range. The sanitizer detects that we're creating and dereferencing pointers outside array boundaries, even though the final memory access happens to land in valid memory.

This changes the functions to use bounds-safe array indexing.
@codebytere codebytere requested a review from lemire July 10, 2025 15:23
@jasnell jasnell merged commit 67e56fd into nodejs:main Jul 10, 2025
6 checks passed
@lemire
Copy link
Member

lemire commented Jul 10, 2025

Is this code ever used outside of v8?

@lemire
Copy link
Member

lemire commented Jul 10, 2025

Or at all?

@anonrig
Copy link
Member

anonrig commented Jul 10, 2025

It's used by nodejs and Cloudflare workers.

@lemire
Copy link
Member

lemire commented Jul 10, 2025

@anonrig Thanks. I'll follow up with my questions elsewhere. :-)

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.

4 participants