Skip to content

state_exec: stabilize document_scope typed-slot identity across DLL boundaries (fixes Windows cvcgl_stream_bind) - #539

Merged
transfix merged 1 commit into
masterfrom
fix/document-scope-cross-dll-type-tag
Oct 2, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/document-scope-cross-dll-type-tag

Conversation

@transfix

@transfix transfix commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Fixes master red on Windows. cvcgl_stream_bind fails in the package-windows / libcvc-release lane (assert(get(app,"t1.ok")=="true") at cvcgl_stream_bind.cpp:69, exit 0xc0000409 = MSVC Release assert fail-fast). Windows-only; Linux/macOS pass. It arrived with the stream merges and is red on master and every open PR.

Root cause: document_scope::slot<T>(key) (added in #524) guards a key against reuse with a different T via an RTTI-free per-type tag — which was the address of a function-local static const char. That address is unique per T within a module but is not merged across shared libraries on Windows (libcvc.dll vs cvcGL.dll each hold their own copy). So a slot created in one module reads back as a tag mismatch → nullptr in another, for the same T. The test publishes a mock StreamBindingSink into the document scope from the test TU and the gl-bind-stream verb (in cvcGL) reads it back; on Windows the mismatch made the verb take its "no GL sink" branch → ok=false → the assert fail-fasted. Linux/macOS merge the static across .so boundaries so the addresses coincided and it passed — hiding the defect (the lane isn't a required check).

Fix: derive the tag from the compiler's function-signature macro (__FUNCSIG__ / __PRETTY_FUNCTION__, which embeds T's name) and compare tags by content (std::strcmp) instead of by address. The same T yields a byte-identical string in every TU and module, so the identity is stable across DLLs while staying RTTI-free; distinct Ts still have distinct signatures, so the reused-key guard is preserved. This fixes the real cross-module seam (a sink published in cvcGL and read across the libcvc↔cvcGL boundary), not just the test.

Verified: cvcgl_stream_bind and the full stream_test (33/33) green on Linux; the Windows lane greens via CI. No behavior change on the matching path.

…LL boundaries

document_scope::slot<T>(key) guards against a key being reused with a different T
via an RTTI-free per-type tag. That tag was the address of a function-local
`static const char` — unique per instantiated T WITHIN a module, but NOT merged
across shared libraries on Windows (libcvc.dll vs cvcGL.dll each get their own
copy). So a slot created in one module read back as a tag MISMATCH (nullptr) in
another, even for the same T.

This made cvcgl_stream_bind fail on Windows only (package-windows / libcvc-release):
the test publishes a mock StreamBindingSink into the document_scope from the test
TU and the gl-bind-stream verb (in cvcGL) reads it back; on Windows the tag
mismatch returned nullptr, the verb took its "no GL sink" error branch, ok=false,
and the Release assert() fail-fasted (exit 0xc0000409). Linux/macOS merge the
static across .so boundaries, so the addresses coincided and it passed — hiding the
defect (the package-windows lane is not a required check).

Fix: derive the type tag from the compiler's function-signature macro
(__FUNCSIG__ / __PRETTY_FUNCTION__), which embeds T's name, and compare tags by
CONTENT (std::strcmp) rather than by address. The same T yields a byte-identical
string in every TU and every module, so the identity is stable across DLLs while
staying RTTI-free; distinct Ts still have distinct signatures, so the reused-key
guard is preserved. Fixes the real cross-module seam (a sink published and read
across libcvc<->cvcGL), not just the test. Verified cvcgl_stream_bind + stream_test
green on Linux; Windows greens via CI.
@transfix
transfix enabled auto-merge October 2, 2026 14:34
@transfix
transfix merged commit b9724c2 into master Oct 2, 2026
13 checks passed
transfix added a commit that referenced this pull request Oct 2, 2026
transfix added a commit that referenced this pull request Oct 2, 2026
@transfix
transfix deleted the fix/document-scope-cross-dll-type-tag branch October 29, 2026 20:53
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