fix(assembly): guard onChanged against solver during document restore #245

Merged
forbes merged 1 commits from fix/assembly-restore-segfault into main 2026-02-16 00:46:19 +00:00
Owner

Problem

Opening documents containing Assembly objects causes a segfault (SIGSEGV) in Assembly::AssemblyObject::validateNewPlacements().

During document restore, PropertyLinkList::Restore sets the Group property on AssemblyObject, which triggers:

onChanged(&Group) → updateSolveStatus() → solve() → validateNewPlacements() → SIGSEGV

At this point, joints reference objects via PropertyXLinkSub links that have not been restored yet — dereferencing these null pointers causes the crash.

Fix

Add an isRestoring() guard to AssemblyObject::onChanged() to skip solver invocation during restore. This matches the existing pattern in AssemblyLink::onChanged() (same file family).

The solver runs properly later when the document is fully loaded and a recompute is triggered.

Stack trace (abbreviated)

#1  Assembly::AssemblyObject::validateNewPlacements()
#2  Assembly::AssemblyObject::solve()
#3  Assembly::AssemblyObject::updateSolveStatus()
#4  Assembly::AssemblyObject::onChanged()
#5  App::Property::hasSetValue()
#8  App::PropertyLinkList::setValues()
#9  App::PropertyLinkList::Restore(Base::XMLReader&)
#11 App::Document::readObjects()
#13 App::Document::restore()
#14 App::Application::openDocumentPrivate()
## Problem Opening documents containing Assembly objects causes a segfault (SIGSEGV) in `Assembly::AssemblyObject::validateNewPlacements()`. During document restore, `PropertyLinkList::Restore` sets the `Group` property on `AssemblyObject`, which triggers: ``` onChanged(&Group) → updateSolveStatus() → solve() → validateNewPlacements() → SIGSEGV ``` At this point, joints reference objects via `PropertyXLinkSub` links that have not been restored yet — dereferencing these null pointers causes the crash. ## Fix Add an `isRestoring()` guard to `AssemblyObject::onChanged()` to skip solver invocation during restore. This matches the existing pattern in `AssemblyLink::onChanged()` (same file family). The solver runs properly later when the document is fully loaded and a recompute is triggered. ## Stack trace (abbreviated) ``` #1 Assembly::AssemblyObject::validateNewPlacements() #2 Assembly::AssemblyObject::solve() #3 Assembly::AssemblyObject::updateSolveStatus() #4 Assembly::AssemblyObject::onChanged() #5 App::Property::hasSetValue() #8 App::PropertyLinkList::setValues() #9 App::PropertyLinkList::Restore(Base::XMLReader&) #11 App::Document::readObjects() #13 App::Document::restore() #14 App::Application::openDocumentPrivate() ```
forbes added 1 commit 2026-02-16 00:45:51 +00:00
fix(assembly): guard onChanged against solver during document restore
Some checks failed
Build and Test / build (pull_request) Has been cancelled
2fa1672edf
During document restore, PropertyLinkList::Restore sets the Group property
on AssemblyObject, triggering onChanged → updateSolveStatus → solve →
validateNewPlacements. At this point joints reference objects that haven't
been restored yet, causing a null pointer dereference (SIGSEGV).

Add an isRestoring() guard to skip solver invocation during restore,
matching the existing pattern in AssemblyLink::onChanged().
forbes merged commit 19a91cb221 into main 2026-02-16 00:46:19 +00:00
forbes deleted branch fix/assembly-restore-segfault 2026-02-16 00:46:20 +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#245