Cache vertex orientations in a signed char, and test Linux on arm64 - #25
Merged
Conversation
vrts_orBin caches orient3D results -- -1, 0 or +1 -- and count_vrt_orBin() reads them back by comparing against -1. It was declared std::vector<char>. Plain `char` is signed on x86-64 and under Apple's arm64 ABI, but UNSIGNED under AAPCS64, which is Linux on arm64. There a stored -1 reads back as 255, the `== -1` comparison never matches, and every vertex lying below a constraint plane is counted as lying above it. splitCell() therefore sees vrtsUNDER == 0 for every constraint, takes the NO SPLIT branch every time, and returns without splitting anything: the BSP complex comes out with exactly as many cells as it went in with and the input surface is silently never embedded. Measured on a 9-vertex, 8-triangle input, native aarch64 Ubuntu 24.04 with GCC 13: initial cells 12162 -> final cells 12162, against 12162 -> 13884 on macOS/arm64 for the same input. Instrumenting the orientation counts showed under=0 on every single constraint, never once nonzero. Six of the 28 integration tests fail on that platform without this change, including "model outputs are byte-stable across platforms", which is precisely the invariant it breaks. With it, all 28 pass and the cell counts match the other platforms exactly. The CI matrix is why this survived: Linux was tested only on x86-64 and arm64 only on macOS, so no job ever compiled the combination. ubuntu-24.04-arm closes that gap. The other std::vector<char> members here (tri_is_flat, used, undecided_sign) only ever hold 0 or 1 and are tested for truthiness, so they are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linux on arm64 silently produces a BSP complex with the input surface never embedded. One-line cause, one-line fix, plus the CI job that would have caught it.
The bug
BSP.hcachedorient3Dresults —-1,0,+1— in astd::vector<char>, andcount_vrt_orBin()reads them back with:charis signed on x86-64 and under Apple's arm64 ABI, but unsigned under AAPCS64 (Linux/arm64). There-1stores as255, the== -1test never matches, and every vertex below a constraint plane is counted as being above it.splitCell()then seesvrtsUNDER == 0for every constraint, takes the NO SPLIT branch each time, and returns having split nothing.Measured
Native aarch64 Ubuntu 24.04, GCC 13, on a 9-vertex / 8-triangle input:
Instrumenting the orientation counts made it unambiguous —
underwas0on every constraint, never once nonzero:The constraint→tet map was fine throughout (
tets_with_constraints=1118, total_entries=1837), so cells did receive their constraints — they were all rejected one step later.Test results, linux/arm64
The six failures include
model outputs are byte-stable across platforms— precisely the invariant this breaks. The suite already detects the bug; nothing had ever run it on arm64 Linux.Why it survived
The matrix tested Linux only on x86-64 and arm64 only on macOS, so no job ever compiled the combination. This adds
ubuntu-24.04-arm(Debug + Release).Scope
The other
std::vector<char>members (tri_is_flat,used,undecided_sign) only ever hold 0/1 and are tested for truthiness — unaffected, left alone.Found while investigating a
wildmeshing-toolkittetwild test failing only on linux/arm64; that repo gets the same CI addition and a pin bump once this lands.🤖 Generated with Claude Code