Skip to content

Initialize Coin standard streams atomically and preserve descriptors on failure - #828

Draft
Dikluwe wants to merge 8 commits into
coin3d:masterfrom
Dikluwe:codex/pr/coin-stdio-core
Draft

Dikluwe wants to merge 8 commits into
coin3d:masterfrom
Dikluwe:codex/pr/coin-stdio-core

Conversation

@Dikluwe

@Dikluwe Dikluwe commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Duplicated standard-stream descriptors were leaked when fdopen failed, and partially initialized global stream state could survive a failed attempt or be observed by concurrent callers.

Changes

  • Serialize lazy stream initialization in thread-safe builds and stage the duplicated FILE resources before publishing global state.
  • Close staged streams and raw duplicates on failure, leave standard descriptors intact, and permit a later retry.
  • Keep cleanup and later initialization cycles consistent.
  • Test descriptor-duplication failures, concurrent acquisition and reuse; a Linux interposer rejects fdopen calls and checks descriptor counts and retry.

This changes Coin's wrappers, not ownership of the process's stdin/stdout/stderr. Lifecycle cleanup still requires callers to stop using resources before shutdown.

Dependencies — keep as draft

Depends on #827. The diff against master includes the prerequisite stack. The contribution over the reviewed base is linked below; narrow/rebase the PR after its prerequisites are integrated.

Base: 246c55d5170f54925723d0d18d52871ad3f4f6cf (codex/pr/coin-atexit-lifetime). Review this contribution over its base.

Validation

Linux candidate 89/89 CTests at f58264c24b11df1314f612732ce5f8a93bdca651, with no skips. Dedicated integration lab previously passed 143/143 at bf09c1e14c49600eac776ba661dc3a0ffa1ba895; 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 337199a6ee3c9f598c81dc52e7692bb1775b0aa6; reviewed contribution base fa442ae4b2f3a71b3928475a5886e038872812ed. 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