fix(#371): stop using XCAFApp_Application::GetApplication() singleton — v1.15.17 - #373
Merged
Merged
Conversation
… (v1.15.17) Per upstream maintainer feedback on OCCT#1396 (our #353 repro): the singleton "exists solely for compatibility reasons"; OCCT's own guidance since 7.1 is a private TDocStd_Application per caller. Every OCCTDocument now builds its own private app instance instead of sharing the process-wide singleton, closing our own exposure to the #341/#344/#349/#353 shared-state race family. A dedicated confirmation harness (private app per thread, zero shared state, zero serialization) found this wasn't a clean win: it surfaced two previously uncaught OCCT races (Resource_Manager::Debug, Storage_Schema::ICurrentData()) that only became reachable once application-instance construction genuinely runs concurrently -- filed upstream as OCCT#1398. ocafStoreMutex() coverage was expanded (not removed) to close the gap; the #344/#349/#353 upstream PRs stay open, since they fix real bugs in a pattern OCCT's own header still documents as the only valid way to get an XCAFApp_Application. Full swift test (4428 tests) clean. TSan gate (bridge-level + 9 kernel-level scenarios, including the new 371 harness) clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 24, 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.
Summary
Per upstream maintainer feedback on OCCT#1396
(our #353 repro issue):
XCAFApp_Application::GetApplication()"exists solely for compatibilityreasons"; OCCT's own guidance since 7.1 is a private
TDocStd_Applicationper caller, not ashared singleton. Our #341/#344/#349/#353 race cluster traced back to every document sharing one
process-wide singleton.
OCCTDocumentnow builds its own private app instance (new TDocStd_Application())instead of grabbing the shared singleton — 9 call sites across
OCCTBridge_Document.mm/OCCTBridge_IO.mm. Confirmed behaviorally equivalent via a ground-truth C++ test beforetouching bridge code.
OCCTDocumentLoadOCAF/OCCTDocumentLoadGLTFeach openeda document through a different app instance than the one stored on the returned
OCCTDocument— harmless only because both were the same shared singleton before this change.state, zero serialization, run against the real TSan-instrumented kernel) found two previously
uncaught races —
Resource_Manager::Resource_Manager()'s unsynchronized globalDebug, andStorage_Schema::ICurrentData()'s unsynchronized globalHandle— only reachable onceapplication-instance construction genuinely runs concurrently, which never happened under the
old shared-singleton pattern. Filed upstream as OCCT#1398.
ocafStoreMutex()(the Concurrent Save/SaveAs to the same format corrupts a shared, cached storage driver instance (SIGSEGV) #349 bridge mitigation) is not redundant after this refactor —coverage was expanded (not removed) to also wrap
OCCTDocumentDefineFormatBin/BinL/Xml/XmlL/ BinXCAF/XmlXCAFandOCCTDocumentCreateWithFormat, previously outside the lock.#1394/#1397)
were not withdrawn — they fix real bugs in a pattern OCCT's own header still documents as
the only valid way to get an
XCAFApp_Application.Bridge-only change — no OCCT kernel patch,
OCCT.xcframeworkunchanged.OCCTBridge.xcframework(the opt-in prebuilt bridge from #339) rebuilt since
Sources/OCCTBridge/src/*.mmchanged;Package.swift's URL/checksum bumped to v1.15.17.Test plan
TDocStd_ApplicationvsXCAFApp_Application::GetApplication()— equivalentswift test(4428 tests / 1285 suites) — clean, re-run twiceScripts/tsan-stress.sh swift(bridge-level TSan, 445 tests) — cleanScripts/tsan-stress.sh run(kernel-level gate, 9 scenarios incl. new371-getapplication-singleton-elimination) — cleanOCCTSWIFT_BRIDGE_PREBUILT=1) — build +OCCTXCAFTestsclean🤖 Generated with Claude Code