btc(v36): complete livelock mirror — hold tracker lock across IO-thread share mutations - #117
Merged
Merged
Conversation
…ad share mutations Mirrors LTC f445db8 onto the BTC twin. PR #97 landed only the watchdog half; the lock-yield half was inert (test-then-release). Two IO-thread sites read/mutated m_tracker.chain racing the compute-thread clean_tracker() exclusive prune (drop_tails), freeing chain nodes mid-access -> SIGSEGV (kr1z1s LTC/DGB shape): - processing_shares_phase2(): held the try_to_lock only to TEST availability, released it, then ran m_tracker.add() lock-free. The unique_lock is now held across the whole mutation body and released just before the async run_think() trigger. BTC-only backpressure cap (MAX_PENDING_ADDS) preserved. - notify_local_share(): bare m_tracker.chain.contains() in the early-return ran outside the lock. Moved under the existing try_to_lock guard (owns_lock() && contains()); on contention the inline verify is skipped and run_think() scores the share next cycle. BTC-only (src/impl/btc/node.cpp). Same non-blocking IO-thread contract (busy -> defer/queue, never block).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the BTC twin of the contabo run_think() livelock / kr1z1s SIGSEGV fix.
Gate
LTC fix has landed on master:
f445db8eltc/node: hold tracker lock across chain access in IO-thread share paths2f9d3e1aFix event-loop freeze: try_to_lock in IO-thread tracker accessesPR #97 (
ee906e8a) landed only the watchdog half of the BTC mirror; the lock-yield half was inert (test-then-release). This PR mirrorsf445db8e1:1 ontosrc/impl/btc/node.cpp.Changes (BTC-only)
try_to_lockonly to TEST availability, released it, then ranm_tracker.add()lock-free on the "think() isnt running" assumption. The compute-threadclean_tracker()prune could grab the lock the instant phase2 released it and free chain nodes mid-mutation → SIGSEGV. Theunique_lockis now held across the whole mutation body and released (lock.unlock()) immediately before the asyncrun_think()trigger. BTC-only backpressure cap (MAX_PENDING_ADDS) preserved inside the!owns_lock()branch.m_tracker.chain.contains()in the early-return ran outside the lock. Moved under the existingtry_to_lockguard (owns_lock() && contains()); on contention the inline verify is skipped andrun_think()scores the share next cycle.Verification
cmake --build build --target c2pool-btc -j16→ BUILD_EXIT=0 (warnings only).e8abf28dGPG-signed.Merge operator-gated.