Skip to content

fix(container): preserve LRU links and insertion state - #284

Merged
nick2781 merged 4 commits into
mainfrom
fix/lru-map-ownership
Nov 4, 2026
Merged

nick2781 merged 4 commits into
mainfrom
fix/lru-map-ownership

Conversation

@nick2781

@nick2781 nick2781 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Copied LRU caches retained recency iterators into the source cache, causing freed-memory access after the source was cleared or destroyed. Prepare empty containers first, rebuild each copied entry and its own recency links, and finish preparing copy assignment before replacing the destination.

Insertion now rolls back partial value/list/index changes when allocation or key copying fails, preserving capacity and eviction order. Existing APIs, class fields and borrowed-pointer semantics remain unchanged; rebuild header consumers. Bilingual guidance and permanent C++ tests are included.

The Windows failure exposed MSVC Debug bookkeeping allocation within a standard-library noexcept constructor. Copy tests now arm failure at the first source lookup after empty-container setup, before any entry is copied. This retains all content-allocation failures, allocating value/key copies, owner release, recovery and independent eviction; full insertion allocation injection also remains. It does not promise recovery from allocation inside standard-library noexcept infrastructure. Iterator debugging, build configuration and sanitizer coverage are unchanged.

The public MySQL lifetime regression also treated successful BEGIN as proof of a still-active transaction ID. Preserve its original 40 ms deadline and cleanup budget, check business success and transaction status separately, and gate unfinished rollback before asserting that shutdown must wait. Deterministic peer-based regressions cover expiry before owner delivery and expiry after a handle is delivered. Production transaction behavior and timeouts are unchanged; bilingual examples now check ID and active status.

Validation: regressions reproduce the source-iterator use-after-free and failed-insert capacity violation on the original main. The repaired check-lru-map passes 6 cases / 120 assertions plus 3 cases / 264 assertions in macOS Debug, and the same checks with AddressSanitizer plus UndefinedBehaviorSanitizer. The relevant public MySQL target passes 7 cases / 656 assertions and its DSO control. Complete clang-format 18 and Nimbus/HTML/Markdown/AI-export checks pass. The preceding candidate passed all three Windows jobs; refreshed protected acceptance remains required for this final head.

@nick2781
nick2781 marked this pull request as ready for review November 4, 2026 02:47
@nick2781
nick2781 added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026
@nick2781
nick2781 added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026
Prepare empty containers before rebuilding values and independent recency links. Keep full insertion allocation injection and sweep copy content allocations from the first source lookup, including allocating value copies and throwing keys.

Add allocation-free terminate diagnostics and document the unrecoverable MSVC Debug noexcept proxy-construction boundary in both languages.
@nick2781
nick2781 added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026
@nick2781
nick2781 added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit ae8c7ed Nov 4, 2026
6 checks passed
@nick2781
nick2781 deleted the fix/lru-map-ownership branch November 4, 2026 10:48
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