Skip to content

build: instrument fetched dependencies under SCN_SANITIZE - #83

Merged
JArmandoAnaya merged 1 commit into
mainfrom
fix/capi-test-duplicate-core-link
Aug 1, 2026
Merged

JArmandoAnaya merged 1 commit into
mainfrom
fix/capi-test-duplicate-core-link

Conversation

@JArmandoAnaya

Copy link
Copy Markdown
Contributor

What

SCN_SANITIZE now applies the same sanitizer flags to the fetched C++
dependencies (googletest, pugixml) that Scena's own targets get.

Why

An AddressSanitizer build on macOS reported a container-overflow in
CApiTest.FollowNurbsTrajectoryFollowsTheCircle, inside the knot-vector
assignment of TrajectoryEvaluator::build_nurbs. The code is correct — the
sanitizer's view of it was not.

libc++ emits its std::vector container annotations only in a translation
unit compiled with -fsanitize=address: the spare capacity is poisoned on
allocation and unpoisoned as elements are constructed. Both halves live in
weak inline templates, so an uninstrumented dependency contributes copies
that poison nothing, and the linker is free to pick a poisoning
__assign_with_size and a non-unpoisoning __construct_at_end for the same
call chain. googletest was the uninstrumented half; Linux happened to
resolve the same weak symbols consistently, which is why the CI sanitizer
job stayed green while every local macOS sanitizer run aborted.

This is a root-cause fix, not a suppression: no check is disabled, no test
is skipped or weakened.

Verification

macOS, -DSCN_SANITIZE=address,undefined -DSCN_BUILD_PYTHON=OFF:

  • before: capi_test aborts on the container-overflow report.
  • after: 875/875 tests pass.

Non-sanitizer builds are unaffected (scn_sanitize_dependency returns
immediately when SCN_SANITIZE is empty).

Docs

CONTRIBUTING.md records why instrumentation has to be uniform across the
process, and that AddressSanitizer builds should use SCN_BUILD_PYTHON=OFF.

libc++ emits its std::vector container annotations only in translation
units compiled with -fsanitize=address, and both halves of the protocol —
poisoning the spare capacity on allocation, unpoisoning it as elements are
constructed — live in weak inline templates. An uninstrumented dependency
contributes non-annotating copies, and the linker is free to pair a
poisoning __assign_with_size with a non-unpoisoning __construct_at_end.

That is what made an AddressSanitizer build on macOS report a
container-overflow in CApiTest.FollowNurbsTrajectoryFollowsTheCircle, in
the knot-vector assignment of TrajectoryEvaluator::build_nurbs: googletest
was the uninstrumented half. The code was correct; the annotations were
not coherent. Linux resolved the same weak symbols consistently, so the CI
sanitizer job never saw it.

googletest and pugixml now get the same sanitizer flags as Scena's own
targets, so a red local sanitizer run means something again. With the fix
the full suite is 875/875 under address,undefined on macOS; it aborted
before.
@JArmandoAnaya
JArmandoAnaya merged commit 7ebc201 into main Aug 1, 2026
9 checks passed
@JArmandoAnaya
JArmandoAnaya deleted the fix/capi-test-duplicate-core-link branch August 1, 2026 14:05
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.

1 participant