Skip to content

cmake: NDEBUG on the mesher's own sources, not all of src/cvc - #882

Merged
transfix merged 3 commits into
masterfrom
build/mesher-ndebug
Oct 30, 2026
Merged

transfix merged 3 commits into
masterfrom
build/mesher-ndebug

Conversation

@transfix

@transfix transfix commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

The mesher block in src/cvc/CMakeLists.txt called add_compile_definitions(... NDEBUG), which puts libcontour's NDEBUG on the whole src/cvc directory: the library and every test under src/cvc/tests, in every build type. The mesher is on by default, so Debug builds of libcvc have run with assert() compiled out, and tests that size themselves by NDEBUG took their Release sizes in Debug. LK-18 on the locks branches ran 3000 operations at 12 a second in the Debug package lanes and timed out. state_exec_async_calls_test.cpp had already worked around it.

Change

  • NDEBUG goes on the vendored mesher sources only (MESHER_SOURCE_FILES, a source property). libcontour set it in every configuration (its contour.pro), and its Debug-only code (dict.c) and asserts have never been compiled, so the mesher builds exactly as before.
  • _BOOL, SP2 and USEDICT stay on the directory. Contour3d's layout depends on USEDICT, and utility/algorithm.cpp includes it (through Mesher/mesher.h, LBIE_Mesher.h, octree.h), so every file that sees it must agree.
  • contour_spectrum_libcontour.cpp is libcvc's own wrapper, so it keeps its asserts.
  • The workaround comment in state_exec_async_calls_test.cpp now describes the old behaviour in the past tense.
  • A mesher bug the first Debug run found. Octree::smoothing_joeliu_volume (JOE_LIU and MINIMAL_VOL) read a tet's fourth vertex as triangles[4*minAspIndx+1][3], one past the 3-element row; the function's other three reads use [2]. recipe / ubuntu-latest / Debug failed GeometryTest.TetrahedralizeWithImprovementMethods on boost::array's (i < N) assert. The mesher's own files still get NDEBUG. But a GCC Debug build doesn't inline operator[], so the linker keeps one copy for the whole program, and the one it kept was compiled without NDEBUG. In the vector's storage the read landed on the next row's [0], so smoothing silently picked the wrong vertex. It now reads [2].

What changes at run time

Only builds without -DNDEBUG in their flags change, which means Debug builds. Release flags carry NDEBUG themselves. In Debug, src/cvc's asserts are live again, along with its vendored SDF code's and stb's, and frame_pool.cpp's debug check. The Debug lanes (recipe / * / Debug, package-linux / libcvc-debug*) are where a dormant assert would fire.

Testing

Windows, MSVC 19.44, built against the cvcpkg deps prefix. A Windows Debug build would need debug-runtime deps, so this used a Release build with NDEBUG taken out of its flags (CMAKE_{C,CXX}_FLAGS_RELEASE=/O2 /Ob2). That leaves assert() live, as in a Debug build. Tests and pycvc were on, cvcGL was off.

  • The build commands show NDEBUG on contour/squeue.cpp and contour/dict.c, and absent on contour_spectrum_libcontour.cpp, utility/algorithm.cpp and tests/state_exec_locks_test.cpp. USEDICT is on all five.
  • ctest, without the CI stress regex: 5286/5286 passed.
  • After the fix, the mesher's own asserts too, via a temporary local build without its NDEBUG: geometry_test 111/111, algorithm_test 10/10, lbie_mesher_test 58/58 and fastcontouring_math_test 32/32 pass in full, with no assert. With [3] put back, TetrahedralizeWithImprovementMethods hits the same assert as CI.

The Linux and macOS Debug lanes are the first runs with these asserts live under GCC and Clang.

The mesher block's add_compile_definitions put libcontour's NDEBUG (its
contour.pro sets it in every configuration) on the whole src/cvc
directory: the library and every test, in Debug builds too, since the
mesher is on by default. assert() was dead in all of them, and tests
that sized themselves by NDEBUG took their Release sizes in Debug.

NDEBUG now goes on the vendored mesher sources only, as a source
property. _BOOL, SP2 and USEDICT stay on the directory: Contour3d's
layout depends on USEDICT, and utility/algorithm.cpp includes it through
Mesher/mesher.h. The contour-spectrum wrapper is libcvc's own code and
keeps its asserts.
@transfix
transfix merged commit ba11026 into master Oct 30, 2026
26 checks passed
@transfix
transfix deleted the build/mesher-ndebug branch October 30, 2026 16:21
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