Fix for Lock Overwrite Issue in Multithreaded RootFillLock Handling #369
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.
The issue occurs when multiple threads call
RootFillLock
. Each thread was independently creating its own lock and overriding the lock saved by the previous thread inm_root_fill_rw_lock
. This resulted in only the last thread's lock being retained. WhenRootFillUnlock
was invoked, all threads attempted to unlock the lock acquired by the last thread, leading to undefined behavior due to multiple unlock operations on the same lock.Resolution:
To address this, an additional check is added after acquiring the write lock. If the lock for the event processor (
proc
) has already been initialized by another thread, that lock will be used. This prevents each thread from initializing a new lock and ensures that only one lock is used across threads.