-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unsafe walking of DacEnumerableHash (#88063)
Under the following set of conditions, it is possible for a lookup in the `DacEnumerableHash` to fail to find already present entries. Given Thread A which is growing the table, and thread B which is attempting to perform a lookup. 1. Thread B reads an `VolatileEntry*` from a bucket in the hashtable. Let this be EntryB. EntryB will have a next pointer which points to EntryThatWeNeedToFind, but it will not yet read that pointer value from EntryB. 2. Thread A reads the pointer to EntryB from the same bucket in the hashtable. 3. Thread A adds EntryB to the new hashtable 4. Thread A sets the bucket in the old hashtable to point to EntryThatWeNeedToFind 5. Thread A sets the next pointer in EntryB to point to NULL. 6. Thread B reads the next pointer, sees that the next pointer is NULL, and falls back to looking in the "new" hashtable for any possible updates 7. Thread B looks in the appropriate bucket in the "new" hashtable. That bucket does not yet contain EntryThatWeNeedToFind, as it hasn't yet been moved from the old hashtable. 8. Thread B returns NULL __*INCORRECTLY*__, indicating that there are no entries with the matching in them. This change adjust how these linked lists work, but giving each one a version number which can be checked as the linked list finishes reading. The fix allows finding entries from an earlier set of buckets (as those can be in the new list temporarily, and will not interfere with finding the correct result), but will actively detect walking entries in the new list when attempting to walk the old entries. In addition, there is a drive by fix for an issue where if there are more than ~14,000,000 entries in the table, it allocates a full new list each time the list is added to. Fixes #85688
- Loading branch information
1 parent
681b798
commit 68b410f
Showing
2 changed files
with
182 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters