fix(assembly): prevent segfault when all joints are removed #310

Merged
forbes merged 1 commits from fix/assembly-empty-joints-segfault into main 2026-02-21 15:48:02 +00:00
Owner

Problem

Removing all joints from an assembly causes a segmentation fault (stack overflow).

Root Cause

updateSolveStatus() calls solve() when lastResult_.placements is empty, but solve() calls updateSolveStatus() at the end. When an assembly has zero constraints (all joints removed), the solver returns zero placements, so lastResult_.placements.empty() remains true on every call — causing infinite recursion until stack overflow.

solve() → updateSolveStatus() → solve() → updateSolveStatus() → ... → segfault

Fix

Add a static re-entrancy guard to updateSolveStatus() so the recursive solve() call is skipped when already on the call stack.

Testing

  1. Open an assembly with joints
  2. Remove all joints
  3. Verify no crash — assembly should remain open with all parts unconstrained
## Problem Removing all joints from an assembly causes a segmentation fault (stack overflow). ## Root Cause `updateSolveStatus()` calls `solve()` when `lastResult_.placements` is empty, but `solve()` calls `updateSolveStatus()` at the end. When an assembly has zero constraints (all joints removed), the solver returns zero placements, so `lastResult_.placements.empty()` remains true on every call — causing **infinite recursion** until stack overflow. ``` solve() → updateSolveStatus() → solve() → updateSolveStatus() → ... → segfault ``` ## Fix Add a static re-entrancy guard to `updateSolveStatus()` so the recursive `solve()` call is skipped when already on the call stack. ## Testing 1. Open an assembly with joints 2. Remove all joints 3. Verify no crash — assembly should remain open with all parts unconstrained
forbes added 1 commit 2026-02-21 15:47:41 +00:00
fix(assembly): prevent segfault when all joints are removed
Some checks failed
Build and Test / build (pull_request) Has been cancelled
b6b0ebb4dc
updateSolveStatus() calls solve() when lastResult_.placements is empty,
but solve() calls updateSolveStatus() at the end. When an assembly has
zero constraints (all joints removed), the solver returns zero
placements, causing infinite recursion until stack overflow (segfault).

Add a static re-entrancy guard so the recursive solve() call is skipped
if updateSolveStatus() is already on the call stack.
forbes merged commit 62f077a267 into main 2026-02-21 15:48:02 +00:00
forbes deleted branch fix/assembly-empty-joints-segfault 2026-02-21 15:48:02 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#310