I am debugging one deadlock case in my application running on RHEL 7(glibc 2.17). When inspecting using gdb, at the time of deadlock, I see the following values on printing std::shared_timed_mutex(which internally uses pthread_rwlock_t):
{<std::__shared_mutex_pthread> = {_M_rwlock = {__data = {__lock = 0, __nr_readers = 0, __readers_wakeup = 3, __writer_wakeup = 397, __nr_readers_queued = 0,
__nr_writers_queued = 1, __writer = -1, __shared = 0, __pad1 = 0, __pad2 = 0, __flags = 0},
__size = "000000000000000006000000010000000000000001000000377377377377", '00' <repeats 27 times>,
__align = 0}}, <No data fields>}
I’m suspicious of the above values, particularly the value seen in ‘__writer’. From what I could understand while looking at the source code of glibc 2.17, __writer should store the thread ID of the thread which has acquired the lock in write mode. So negative value doesn’t make any sense.
Is this some valid value? Can this invalid value be somehow related to the deadlock I’m seeing in my application? Or is this due to gdb not able to properly inspect the mutex(maybe due to some version mismatch. Just guessing).
Also what exactly is the meaning of the values seen in __writer_wakeup and __readers_wakeup? I understand the queued variables but what are these wakeup variables?
5