Skip to content

Keep Coin cleanup registration valid across reentrant shutdown - #827

Open
Dikluwe wants to merge 3 commits into
coin3d:masterfrom
Dikluwe:codex/pr/coin-atexit-lifetime
Open

Dikluwe wants to merge 3 commits into
coin3d:masterfrom
Dikluwe:codex/pr/coin-atexit-lifetime

Conversation

@Dikluwe

@Dikluwe Dikluwe commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Cleanup registration can precede tidbits initialization, and destroying its lock during cleanup can leave callers using a freed lock. Nested SoDB::finish() can mark the database uninitialized while the outer cleanup still needs it.

Changes

  • Give cleanup registration a mutex that outlives initialization/cleanup cycles in thread-safe builds, and an atomic exit state.
  • Run callbacks outside the registration lock; nested cleanup returns to the outer cleanup.
  • Preserve SoDB initialization until the outer cleanup finishes, reset state for later cycles, and avoid cleanup-debug registration recursion on Windows.
  • Explicitly reject NULL callbacks and registration during active cleanup; make equal sort keys compare equal.

Regressions cover early registration, ordering, repeated cycles, nested cleanup, database use during nested finish, and invalid-registration aborts where process isolation is available. This does not establish concurrent SoDB::init()/finish() support.

Base

Independent contribution over upstream master; no unpublished prerequisite is required.

Upstream master: ca247c1321bce07199ec0f034493977761b3218e.

Validation

Linux candidate 86/86 CTests at 246c55d5170f54925723d0d18d52871ad3f4f6cf, with no skips. Dedicated integration lab previously passed 140/140 at 105c9eb80ce411a8d545dcef3f9c93f4fba292cb; that lab count is a separate reviewed snapshot.

Fresh publication gate of all eight exact heads: 35/35 directed and 153/153 total CTests, no skips, at e6687c088077082e6839b4fc39c632d5267b07d8. GCC/Ninja Debug shared build with COIN_THREADSAFE=ON and external Expat, build and compiler temporary files in RAM; Xvfb/software GLX environment. git diff --check passed for the proposed delta. Native Windows/macOS and formal ABI checks rerun on this published head.

Windows DLL fixture correction — 2026-10-09

The first Windows run could not link CoinAtexitTest because it called private, non-exported coin_is_exiting. The fixture now checks callback ordering, initialization during reentrant finish, completed shutdown and restart through exported public SoDB APIs. Production code and public symbols are unchanged by this correction. It is propagated from #827 through #828–#830.

Current head fa442ae4b2f3a71b3928475a5886e038872812ed; reviewed contribution base ca247c1321bce07199ec0f034493977761b3218e. The refreshed #827 candidate passed 86/86, and the exact published composition passed 35/35 directed and 153/153 full CTests, no skips, at e5c732433599f2407c83ab50cdcb1cd9f23221c8 (GCC/Ninja Debug shared, thread safety, external Expat, RAM/Xvfb/software GLX). Earlier individual counts above refer to their recorded snapshots. Native CI reruns on these heads.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant