You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pattern is in SDL_properties.c in several places:
if (SDL_LockRWLockForReading(SDL_properties_lock) ==0) {
SDL_FindInHashTable(SDL_properties, (constvoid*)(uintptr_t)props, (constvoid**)&properties);
SDL_UnlockRWLock(SDL_properties_lock);
}
The problem is that SDL_FindHashInTable() will modify the hash...
/* Matched! Move to the front of list for faster lookup next time. (stackable tables have to remain in the same order, though!) */if ((!table->stackable) && (prev!=NULL)) {
SDL_assert(prev->next==i);
prev->next=i->next;
i->next=table->table[hash];
table->table[hash] =i;
}
...and if two things have a read lock and come through here at the same time, it'll corrupt the hashtable.
So we should decide if we want to either move SDL_properties_lock to a normal mutex, or remove the optimization in SDL_FindInHashTable. I guess it's a question of which is more likely: multiple lookups of the same thing, or multiple threads looking stuff up in parallel.
If we remove the optimization, we should also move SDL_Properties::lock over to a RWlock.
The text was updated successfully, but these errors were encountered:
(I'm inclined to say remove the optimization, so multiple threads can read from a hashtable simultaneously without using a lock at all when the hash is otherwise static...and also because this is a surprising implementation detail of the hashtable one wouldn't guess from the interface.)
This pattern is in SDL_properties.c in several places:
The problem is that SDL_FindHashInTable() will modify the hash...
...and if two things have a read lock and come through here at the same time, it'll corrupt the hashtable.
So we should decide if we want to either move SDL_properties_lock to a normal mutex, or remove the optimization in SDL_FindInHashTable. I guess it's a question of which is more likely: multiple lookups of the same thing, or multiple threads looking stuff up in parallel.
If we remove the optimization, we should also move SDL_Properties::lock over to a RWlock.
The text was updated successfully, but these errors were encountered: