Title: [291097] trunk/Source/bmalloc
- Revision
- 291097
- Author
- [email protected]
- Date
- 2022-03-10 02:19:47 -0800 (Thu, 10 Mar 2022)
Log Message
[libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set
https://bugs.webkit.org/show_bug.cgi?id=237697
rdar://89116983
Reviewed by Mark Lam.
To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this
small stash is used to keep old table and size while resizing. However, Mark pointed that
pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's
underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that
in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized).
This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is
enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process.
Thus, data structure's consistency between instruction boundary is enough.
* libpas/src/libpas/pas_hashtable.h:
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (291096 => 291097)
--- trunk/Source/bmalloc/ChangeLog 2022-03-10 09:30:38 UTC (rev 291096)
+++ trunk/Source/bmalloc/ChangeLog 2022-03-10 10:19:47 UTC (rev 291097)
@@ -1,3 +1,23 @@
+2022-03-09 Yusuke Suzuki <[email protected]>
+
+ [libpas] We should gurantee that in-flux-stash is fully baked when pointing table is set
+ https://bugs.webkit.org/show_bug.cgi?id=237697
+ rdar://89116983
+
+ Reviewed by Mark Lam.
+
+ To support enumerating hashtable which can be in the middle of resizing, we have in-flux-stash: this
+ small stash is used to keep old table and size while resizing. However, Mark pointed that
+ pas_tiny_large_map_hashtable_for_each_entry_remote's assertion is firing, which is ensuring that table's
+ underlying pointer should be NULL when the size is 0. But in-flux-stash, we did not guarantee that
+ in-flux-stash data is consistent when it is exposed to the enumerator (when setting hashtable_being_resized).
+
+ This patch inserts pas_compiler_fence when exposing and unexposing in-flux-stash. pas_compiler_fence is
+ enough (pas_store_store_fence is not necessary) because pas_enumerator runs after suspending the process.
+ Thus, data structure's consistency between instruction boundary is enough.
+
+ * libpas/src/libpas/pas_hashtable.h:
+
2022-03-08 Yusuke Suzuki <[email protected]>
[libpas] Report more actionable crash in pas_enumerator
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_hashtable.h (291096 => 291097)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_hashtable.h 2022-03-10 09:30:38 UTC (rev 291096)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_hashtable.h 2022-03-10 10:19:47 UTC (rev 291097)
@@ -149,10 +149,11 @@
PAS_TESTING_ASSERT(!in_flux_stash->hashtable_being_resized); \
in_flux_stash->table_before_resize = old_table; \
in_flux_stash->table_size_before_resize = old_size; \
+ pas_compiler_fence(); /* When hashtable_being_resized is pointing at table, table_before_resize and table_size_before_resize need to be right values. */ \
in_flux_stash->hashtable_being_resized = table; \
} \
pas_compiler_fence(); \
- \
+ /* We do not need to ensure the ordering of the following stores since in-flux-stash is effective while running this code. */ \
table->table = new_table; \
table->table_size = new_size; \
table->table_mask = new_table_mask; \
@@ -161,6 +162,7 @@
pas_compiler_fence(); \
if (in_flux_stash) { \
in_flux_stash->hashtable_being_resized = NULL; \
+ pas_compiler_fence(); /* We should clear hashtable_being_resized first to tell memory enumerator that in_flux_stash is no longer effective. */ \
in_flux_stash->table_before_resize = NULL; \
in_flux_stash->table_size_before_resize = 0; \
} \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes