Skip to content

test(nav): headless sim_world ABI-skew canary - #775

Merged
transfix merged 2 commits into
masterfrom
test/nav-sim-world-abi-canary
Oct 24, 2026
Merged

transfix merged 2 commits into
masterfrom
test/nav-sim-world-abi-canary

Conversation

@transfix

Copy link
Copy Markdown
Owner

What

Adds nav_sim_world_test, a headless (no cvcGL / VTK / OpenGL) gtest that exercises exactly the path nav_city_swarm runs at startup before it opens a GL context:

city_scene → from_occupancy → size()/planes()/agent_planes() → snapshot → step

across shared / grouped / private belief modes, and wires it into ctest (src/cvc/tests/CMakeLists.txt).

Why

That startup path is the source of the long-standing nav_city_swarm startup crash. The root cause is an ABI / struct-layout skew — not an uninitialized read. sim_world embeds config (which holds veh_params) and material_config by value, both of which grow as nav work lands (the footprint/steering/grip fields, the injected thread-pool, …), so sizeof(sim_world) changes in the headers. A cvc library built from an older layout returns a wrong-sized sim_world by value, so size()/planes() read garbage (512 came back as 236190608) and the by-value return smashes the caller's stack (the rip=0 / ret-to-null seen in the crash dumps).

It was invisible to AddressSanitizer because it is a layout mismatch, not a heap error — the ASan build simply rebuilt cvc from source, erasing the skew.

EXPECT_EQ(w.size(), N) is the canary: it fails loudly ("expected 512, got 236190608") the instant a consumer is built against headers whose sim_world layout disagrees with the linked cvc — e.g. a published deps bundle lagging the source tree. In a consistent build it is a cheap from_occupancy / snapshot / step regression test.

Verification

  • Does not currently reproduce. The installed nav_city_swarm.exe runs clean, and a fresh headless program built from today's headers against the installed deps/cvc.lib returns size()=5 / 512 correctly — the installed library and headers are ABI-consistent. This test is a preventive guard so the skew can't silently return the next time deps lags a layout change.
  • The exercised nav path is clean under Valgrind memcheck (--track-origins): 0 uninitialised-value errors across shared/grouped/private modes — confirming there is no latent uninit read; the failure mode is purely build/layout consistency.

Test-only; no source behavior change.

nav_sim_world_test runs nav_city_swarm's GL-free startup path
(city_scene -> from_occupancy -> size/planes/agent_planes -> snapshot ->
step) and asserts size() == the requested agent count, across shared /
grouped / private belief modes.

That startup path produced the long-standing nav_city_swarm startup
crash. The root cause is an ABI/layout skew, not an uninitialized read:
sim_world embeds config (which holds veh_params) and material_config by
value, both of which grow as nav work lands, so sizeof(sim_world) changes
in the headers. A cvc library built from an older layout returns a
wrong-sized sim_world by value, so size()/planes() read garbage (512 came
back as 236190608) and the by-value return smashes the caller's stack
(the rip=0 / ret-to-null in the dumps). It was invisible to
AddressSanitizer because it is a layout mismatch, not a heap error -- the
ASan build simply rebuilt cvc from source and erased the skew.

EXPECT_EQ(w.size(), N) is the canary: it fails loudly ("expected 512, got
236190608") the instant a consumer is built against headers whose
sim_world layout disagrees with the linked cvc -- e.g. a published deps
bundle lagging the source tree. In a consistent build it is a cheap
from_occupancy/snapshot/step regression test. Test-only; no behavior
change.
git-clang-format flagged the changed lines: IncludeBlocks: Regroup +
SortIncludes want one sorted include block (vector after gtest), matching
the repo convention. No code change.
@transfix
transfix merged commit ab3a619 into master Oct 24, 2026
24 checks passed
@transfix
transfix deleted the test/nav-sim-world-abi-canary branch October 24, 2026 05:58
transfix added a commit that referenced this pull request Oct 24, 2026
Carries the master merge (#776 squash, #774, #775, #777, #780, #782,
#784, #785) up the H1 stack.
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