[draft] [test] Fix for concurrent multi-attach test#5359
Draft
saxena-anurag wants to merge 14 commits into
Draft
[draft] [test] Fix for concurrent multi-attach test#5359saxena-anurag wants to merge 14 commits into
saxena-anurag wants to merge 14 commits into
Conversation
Instead of preventing cleanup on worker threads (which left leftover program state), use a static CRITICAL_SECTION to serialize link cleanup across all threads. This prevents races where one thread detaches links while another is attaching them, while still ensuring all threads clean up their state. - Add _cleanup_lock static mutex to _native_module_helper - Initialize/destroy lock via static helper object - Wrap bpf_link cleanup sequence in EnterCriticalSection/LeaveCriticalSection This fixes API test failures that were caused by leftover programs from previous test runs polluting the system state.
…d cleanup" This reverts commit 51a2f64.
…ebpf-for-windows into user/anusa/issue_5238
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.
Description
Fixes a race in test setup for native helper initialization by limiting global link cleanup to the main thread only. Closes #5238.
Problem
_native_module_helper::initialize()detached all existing BPF links unconditionally. In multi-threaded test runs, worker threads could execute this cleanup concurrently and detach links that were just created by other threads, causing intermittent/racy attach failures.Change
In tests/libs/util/native_helper.cpp, move the link cleanup loop behind an
_is_main_threadguard:_is_main_threadbefore anyREQUIREcalls, as before.bpf_link_get_next_id/bpf_link_get_fd_by_id/bpf_link_detachcleanup only whenis_main_thread == true.This preserves cleanup semantics for the primary test thread while preventing worker threads from interfering with freshly attached links.
Testing
Existing CICD.
Documentation
No documentation impact.
Installation
No installer impact.