Skip to content

fix: make allocator lifecycle and teardown concurrency-safe - #42

Open
damian123 wants to merge 12 commits into
andyD123:mainfrom
damian123:fix/concurrent-vector-allocator
Open

damian123 wants to merge 12 commits into
andyD123:mainfrom
damian123:fix/concurrent-vector-allocator

Conversation

@damian123

@damian123 damian123 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Important

Depends on #29. After #29 lands, rebase this branch onto updated main before merge.

Summary

This is the focused allocator safety change, without the PDE executor or numerical modules.

  • synchronizes registry creation, allocation, return, policy removal, and cleanup
  • fixes non-LIFO block reuse and prevents duplicate live blocks
  • rejects freeAll and size-specific policy removal while blocks are live
  • makes AllAllocatorsGuard teardown explicitly nonthrowing for the expected live-block refusal
  • diagnoses unknown, wrong-size, and double returns when the DR3 library is built in Debug mode
  • keeps Release-library invalid returns as legacy no-ops without changing live counts
  • fixes VecBool destruction to return its actual padded pool size
  • makes policy publication exception-safe
  • documents the heap-allocated registry and mutex as intentional process-lifetime objects

The process-lifetime registry design still means leak detection remains a later allocator-lifetime redesign item; this PR does not claim to solve that architectural issue.

Concurrency contract

Different threads may allocate, use, and destroy independently owned Vec/VecD values. Concurrent mutation of the same value remains unsupported. Workers and pool-backed values must be destroyed before explicit global cleanup.

Verification

Sixteen focused allocator/concurrency tests cover concurrent first use, mixed sizes, cross-thread destruction, alignment, cleanup refusal, policy removal, nonthrowing guard teardown, padded VecBool destruction, Debug diagnostics, Release no-op behavior, and repeated startup/shutdown.

Passed locally after restacking on the current #29 head:

  • GCC Debug and Release
  • GCC Debug ASan/UBSan
  • full portable and focused allocator CTest
  • git diff checks

Register the AVX2 VectorTest suite with CMake/CTest, fetch GoogleTest
portably, pin GitHub Actions, and run tests on Windows MSVC and Ubuntu
GCC/Clang. Fix Span::empty to compare instead of assign so Clang
builds. Keep the portable translation units on all compilers; extra
MSVC-only sources remain opt-in.
Share a single AllAllocatorsGuard in testNamespace.cpp so MSVC does
not see a duplicate symbol. Drop the extra MSVC-only VectorTest
sources from the portable target. Exclude ApplyFilterB from CTest
(fails in Debug). Do not fail the required matrix on known allocator
ASan teardown reports.
CMake 4.x POST_BUILD discovery fails on Windows multi-config
generators. Register the portable suite as a single CTest entry.
AllAllocatorsGuard in other TUs ran after the static unordered_map
members were destroyed, so VectorTest segfaulted on Windows after
gtest had already reported 29/29 passed. Store the size-to-policy
map on the heap and reset the cached policy pointer in freeAll.
Return the transformed scalar value and select the last valid partial-scan lane so transformed padding cannot enter unary or bivariate results.
@damian123
damian123 force-pushed the fix/concurrent-vector-allocator branch from 5857cc6 to 47de883 Compare August 31, 2026 13:28
@damian123 damian123 changed the title fix: make vector allocator lifecycle concurrency-safe fix: make allocator lifecycle and teardown concurrency-safe Aug 31, 2026

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