Repository navigation
fem: a stepped Poisson solve with one source value reads it before filling f - #903
Merged
Merged
Conversation
…lling f stepped_solve's begin() spread a one-value source over every vertex with f.assign(nv, f[0]), passing a reference into f itself. assign(n, t) requires that t is not a reference into the vector. libstdc++ copies t before it reallocates, so Linux and Windows were right. libc++ frees the old buffer first (__vdeallocate, then __construct_at_end(n, u)), so on macOS every vertex got whatever freed memory held. Fem.SteppedPoissonMatchesTheOneShotSolve's "a single source value" case then differed from fem::solve_poisson by 9.7% (macOS recipe Release, run 41005671302). The value is now copied first.
This was referenced Oct 30, 2026
transfix
pushed a commit
that referenced
this pull request
Oct 30, 2026
Takes #903's fix for the stepped Poisson solve in place of the same fix made here.
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.
Fem.SteppedPoissonMatchesTheOneShotSolvefails on macOS, in its last case, "a single source value" (fem_test.cpp:612). The stepped solve differs fromfem::solve_poissonby a max relative 0.0968, where the test allows under 1e-10. It came with #890, whose macOS jobs were cancelled before it merged. Since then it has turned the macOS Release lane red on every PR built on master. It was first seen on #885 (run 41005671302, job 123899893970).Cause
stepped_solve::impl::begin()(src/cvc/geometry/fem.cpp) spread a one-value source over every vertex like this:f.assign(es.nv, f[0]);assign(n, t)requires thattis not a reference into the container, and here it is one. libstdc++ copiestbefore it reallocates, so the Linux and Windows lanes were right. libc++ 17 frees first:fholds one element, so filling it tonvtakes the reallocating branch. Every vertex then got whatever the freed block held instead of -6. The one-shotsolve_poissonfills a separaterhsvector, so it was always right. That is why only the stepped solve's single-value case differed. The varying-source cases earlier in the test pass on macOS.Fix
Copy
f[0]before theassign. I found no otherassign,resizeorinsertinsrc/orinc/that takes its value from the same container.Testing
recipe / macos-latest / ReleaseandDebugshould passFem.SteppedPoissonMatchesTheOneShotSolve.CVC_ENABLE_LIBIGLdefined, fem.cpp compiles warning-free apart from the existingtypes.hones. The full libigl test build wasn't run, because libigl isn't installed in this machine's prefix. On libstdc++ the behaviour doesn't change.git clang-format(18.1.3): no changes.