Skip to content

docs(security): bounds.md bad-run example is caught by libstdc++'s assertion, not ASan, on GCC 15+ #364

Closed

Description

@homer6

docs/security/bounds.md#check-before-the-access/1 fails the GCC 16 snippet run (local gcc:16, v0.5.0 release checks, #363): "bad run block wasn't caught by a sanitizer (exit -6)". libstdc++ 15+ enables _GLIBCXX_ASSERTIONS by default without optimization, so vector::operator[] asserts (__n < this->size()) before ASan sees the read. The example's point holds; only the mechanism differs. The enforced GCC 15/16 Linux CI jobs will hit it too.

Fix: index through the pointer and length a C interface would hand over (table.data()), so the read is unchecked on every library and ASan reports it, and say on the page that vector::operator[] itself is stopped by libstdc++'s assertion in unoptimized builds.

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. homer6 commented on Nov 3, 2026

    @homer6
    OwnerAuthor

    Delivered in #366.

    What changed

    • The bad run example indexes through a pointer, so ASan reports it on every library; the page explains libstdc++'s default assertion.

    Why

    • GCC 16's libstdc++ assertion aborted first, failing the snippet check. Verified on GCC 16, Clang 22 and GCC 15.
  3. homer6 commented on Nov 3, 2026

    @homer6
    OwnerAuthor

    Merged in #366 (c4093cf).

    What changed

    • Nothing since the PR was opened: no follow-up commits and no rebase.

    Why

    • Merged on the owner's review; the PR's Tested section has the local checks.

    Still open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions