CNA-BUG-275: CnaTests sources call POSIX setenv and unsetenv without a platform guard, and the check that refused such calls is no longer registered

CNA snapshot b0e97bb1  ·  Known Issues › Current bugs  ·  source links pinned to b0e97bb1

✓

Evidence basis: source-verified at the pinned commit; inferred from the source (the behaviour was not run). Claims on this page were checked by reading the CNA source at commit b0e97bb1; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.

IndexedDrawDeferredTests.cpp, compiled into CnaTests on every target, calls ::setenv and ::unsetenv outside any guard; MinGW-w64 has neither, so a Windows cross-built CnaTests cannot compile, and nothing runs CNA's own setenv check any more.

Identifier
CNA-BUG-275
Category
Bug
Subsystem
Build & CI
Status
Open
Verified against
CNA b0e97bb1 (b0e97bb1bb876f9b3edd6f4ff1ef3067908ae8ac)
Severity
Medium (a triage suggestion, not a project priority)
Evidence basis
Inferred (strong): follows from the code, but the behaviour was not run
Tests touching this area
None
Affected contract
CnaTests in MinGW-w64 cross trees; CNA's rule (docs/cnatests-mingw-setenv-proposal.md, scripts/check_no_posix_setenv.py) that tests set environment variables through System::Environment::SetEnvironmentVariable, not POSIX setenv/unsetenv

Expected behaviour

CNA's own rule, recorded in cnatests-mingw-setenv-proposal.md and checked by check_no_posix_setenv.py: MinGW-w64 has no setenv/unsetenv, so a single call in a translation unit that reaches a Windows cross build stops CnaTests.exe compiling; tests use System::Environment::SetEnvironmentVariable(name, value) instead (an empty value unsets).

Actual behaviour at TARGET

CpuBaseVertexSwitch in IndexedDrawDeferredTests.cpp (added by 1dc4ce06a, CBIND-139) calls ::setenv("CNA_EASYGL_CPU_BASE_VERTEX", "1", 1) and ::unsetenv(...) outside any preprocessor guard, and UnitTests.cmake compiles every modules/*/tests/*.cpp into CnaTests (GLOB_RECURSE CNA_TEST_SOURCES) on every target, MinGW-w64 cross trees included. The CTest that ran the check, CNAEXT_NoPosixSetenv, is no longer registered (5572f3ca1); the script is still in the tree, but no CMake file or workflow runs it. The same scan finds 53 non-comment call lines in 18 files under modules/ and tools/, most of them in GamerServices and Wayland tests and demos (some behind POSIX guards; not checked one by one). EffectSourceCommandLineTests.cpp still tells readers that the CNAEXT_NoPosixSetenv CTest refuses such calls.

Source locations

Evidence

Read at b0e97bb1; nothing was built. The scan repeats the pattern of check_no_posix_setenv.py (non-comment lines of *.cpp and *.hpp under modules, tools and tests, third-party trees skipped) over the Git objects: 12 lines in 5 files at the previous snapshot 009d40f5, 53 lines in 18 files at b0e97bb1. That a MinGW-w64 build of CnaTests fails to compile is inferred from CNA's own record of the same blocker (the proposal document), not observed; no workflow builds CnaTests for a Windows target.

Focused reproduction

No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.

Current tests

None: no CMake file or workflow runs check_no_posix_setenv.py, and no workflow builds CnaTests for a Windows target (d3d-windows-ci.yml states that CnaTests is out of its scope).

Regression test

Replace the calls with System::Environment::SetEnvironmentVariable (or guard them to POSIX hosts) and register check_no_posix_setenv.py again as a CTest or workflow step over modules/, tools/ and tests/.

Blast radius

Every MinGW-w64 build of CnaTests, which the Direct3D renderers rely on for their unit-test binary under Wine. Linux, macOS and other POSIX builds are unaffected.

Workaround

Patch the call sites to System::Environment::SetEnvironmentVariable locally before a Windows cross build of CnaTests.

The same subject is explained at several altitudes. These are the neighbouring pages at each one.

Known issues
Bug index