I have a system level code that periodically starts timers and has a signal handler that controls these signals when they arrive. This works great and seems quite reasonable. There are also two separate threads that go along with the main program, but they do not use any variables, but they use asynchronous glib queues to send messages in only one direction.
In the same code, glib is used GHashTableto store, well, key / value pairs. When the signal code is commented out outside the system, the hash table seems to be working fine. However, when it is turned on, there is a strange race condition when the call g_hash_table_lookupreally returns NULL (this means that there is no record with the key used for searching) when the record is really there (yes, I made sure by printing the whole list of key / pairs value with g_hash_table_foreach). Why does this happen in most cases? Is GLib hash table implementation an error? Sometimes the search is successful.
This is a very specific situation, and I can clarify if this makes no sense, but I hope that I am doing something wrong so that this can be fixed.
Additional information: code segments that are not in the scope of the signal handler, but access to the g_hash_table variable is surrounded by signal blocking calls, so the signal handler does not gain access to these variables when the process initially accessed them.
source
share