Do not build a PickedPoint from a pick that addresses nothing - #6772
Merged
Conversation
pointOnObjectToPickedPoint() fed pos.face straight into Mesh::toTriPoint(), which indexes edgePerFace_ by it, so a pick carrying an out-of-range face read out of bounds. That is a live crash: the MeshInspector UI test create_feature_sphere died with SIGSEGV inside toTriPoint() under PickPointManager::onMouseDown_ on Ubuntu 26.04, whose much newer llvmpipe (LLVM 21.1.8, Mesa 26.0.8) evidently returns a different pick than the 22.04 and 24.04 legs, which pass. Validate the address against the object before converting - the face against the topology, the vertex against validPoints, the edge against the polyline - and return std::monostate, which the header already documents as "not valid pick". The warning names the offending id so a bogus pick is visible in the log instead of being silently dropped. PickPointManager::onMouseDown_ then refuses to append such a point; it used to pass the conversion result on unchecked.
This was referenced Sep 3, 2026
Grantim
approved these changes
Sep 4, 2026
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.
The crash
MeshInspector's
create_feature_sphereUI test died with SIGSEGV on the Ubuntu 26.04 leg of MeshInspectorCode#7746, on the mouse-down pick right after the BestFit Sphere activation:pointOnObjectToPickedPoint()fedpos.facestraight intoMesh::toTriPoint(), which callstopology.edgeWithLeft( f )— an uncheckededgePerFace_[f]. So a pick carrying a face that the topology does not have is an out-of-bounds read, and a nullmesh()is a null dereference. The sibling function directly below,getPickedPointPosition(), already validates withtopology.hasEdge(...)before touching anything; this one did not.The fix
Validate the address against the object before converting, in all three branches:
mesh()non-null,pos.facevalid andtopology.hasFace( pos.face )pointCloud()non-null,pos.vertvalid and invalidPointspolyline()non-null, the edge valid andtopology.hasEdge(...)and otherwise return
std::monostate, which MRPointOnObject.h already documents as "means not valid pick (pick in empty space)" — so this is the variant's existing vocabulary, not a new convention. The header comment now says so on the function too.The
spdlog::warnnaming the offending id is deliberate: a pick that addresses nothing should be visible in the log rather than silently dropped, and it is what will tell us whether the 26.04 pick really is bogus (see below).PickPointManager::onMouseDown_()passed the conversion result toappendPoint()unchecked, which would now append amonostatepoint; it refuses instead.Why only Ubuntu 26.04, and what is still open
The 22.04 (Clang) and 24.04 (GCC 14) legs pass this same UI test in the same run. 26.04 runs a much newer software GL stack under xvfb —
llvmpipe (LLVM 21.1.8, 256 bits),Mesa 26.0.8— and the pick is read back from a rendered buffer, so a different renderer plausibly yields a different (here: unusable) pick result.That is a hypothesis, not a proven root cause, and this PR does not claim to fix it: it converts an out-of-bounds read into a rejected pick and a log line. If the warning fires on 26.04 with an out-of-range face, the pick is confirmed bogus and the remaining question is why the renderer produces it. If the crash were to persist without the warning, the input was valid and the fault lies elsewhere — equally worth knowing.
Guarding is correct regardless of the answer: a pick arriving from a GPU read-back is untrusted input.
Verification
MRMesh.vcxprojandMRViewer.vcxprojbuild clean locally (Release x64, 0 warnings). The instrumented run on the 26.04 leg is what settles the pick question, and I will report what the log says.