Closed RaiqaRasool closed 1 month ago
Line 236 introduces a small memory leak. The lock object should not be instantiated until inside the if-block that saves it.
Line 236 introduces a small memory leak. The lock object should not be instantiated until inside the if-block that saves it.
Corrected!
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.