Title: [289268] branches/safari-613-branch/Source/bmalloc
Revision
289268
Author
[email protected]
Date
2022-02-07 18:52:51 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r287991. rdar://problem/87557006

    [libpas] add assertions that we aren't switching to a NULL lock
    https://bugs.webkit.org/show_bug.cgi?id=235190

    Reviewed by Yusuke Suzuki.

    This adds a pas_panic call when pas_local_allocator_stop sees a NULL page->lock_ptr. That's one
    possible explanation of a very rare crash I'm seeing where return_memory_to_page fails its assertion
    that we are holding the page lock.

    This also adds TESTING asserts in a bunch of other places. The PAS_TESTING_ASSERTS about this are in
    places that are perf-sensitive, so we probably cannot assert in production. The hope behind those is
    that it will help to catch this issue in test_pas.

    * libpas/src/libpas/pas_local_allocator.c:
    (stop_impl):
    * libpas/src/libpas/pas_segregated_page.c:
    (pas_segregated_page_switch_lock_and_rebias_while_ineligible_impl):
    * libpas/src/libpas/pas_segregated_page_inlines.h:
    (pas_segregated_page_lock_with_unbias_not_utility):
    (pas_segregated_page_lock_with_unbias):
    (pas_segregated_page_lock):
    (pas_segregated_page_switch_lock_impl):
    (pas_segregated_page_switch_lock_with_mode):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287991 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/bmalloc/ChangeLog (289267 => 289268)


--- branches/safari-613-branch/Source/bmalloc/ChangeLog	2022-02-08 02:52:48 UTC (rev 289267)
+++ branches/safari-613-branch/Source/bmalloc/ChangeLog	2022-02-08 02:52:51 UTC (rev 289268)
@@ -1,5 +1,63 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r287991. rdar://problem/87557006
+
+    [libpas] add assertions that we aren't switching to a NULL lock
+    https://bugs.webkit.org/show_bug.cgi?id=235190
+    
+    Reviewed by Yusuke Suzuki.
+    
+    This adds a pas_panic call when pas_local_allocator_stop sees a NULL page->lock_ptr. That's one
+    possible explanation of a very rare crash I'm seeing where return_memory_to_page fails its assertion
+    that we are holding the page lock.
+    
+    This also adds TESTING asserts in a bunch of other places. The PAS_TESTING_ASSERTS about this are in
+    places that are perf-sensitive, so we probably cannot assert in production. The hope behind those is
+    that it will help to catch this issue in test_pas.
+    
+    * libpas/src/libpas/pas_local_allocator.c:
+    (stop_impl):
+    * libpas/src/libpas/pas_segregated_page.c:
+    (pas_segregated_page_switch_lock_and_rebias_while_ineligible_impl):
+    * libpas/src/libpas/pas_segregated_page_inlines.h:
+    (pas_segregated_page_lock_with_unbias_not_utility):
+    (pas_segregated_page_lock_with_unbias):
+    (pas_segregated_page_lock):
+    (pas_segregated_page_switch_lock_impl):
+    (pas_segregated_page_switch_lock_with_mode):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287991 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-13  Filip Pizlo  <[email protected]>
+
+            [libpas] add assertions that we aren't switching to a NULL lock
+            https://bugs.webkit.org/show_bug.cgi?id=235190
+
+            Reviewed by Yusuke Suzuki.
+
+            This adds a pas_panic call when pas_local_allocator_stop sees a NULL page->lock_ptr. That's one
+            possible explanation of a very rare crash I'm seeing where return_memory_to_page fails its assertion
+            that we are holding the page lock.
+
+            This also adds TESTING asserts in a bunch of other places. The PAS_TESTING_ASSERTS about this are in
+            places that are perf-sensitive, so we probably cannot assert in production. The hope behind those is
+            that it will help to catch this issue in test_pas.
+
+            * libpas/src/libpas/pas_local_allocator.c:
+            (stop_impl):
+            * libpas/src/libpas/pas_segregated_page.c:
+            (pas_segregated_page_switch_lock_and_rebias_while_ineligible_impl):
+            * libpas/src/libpas/pas_segregated_page_inlines.h:
+            (pas_segregated_page_lock_with_unbias_not_utility):
+            (pas_segregated_page_lock_with_unbias):
+            (pas_segregated_page_lock):
+            (pas_segregated_page_switch_lock_impl):
+            (pas_segregated_page_switch_lock_with_mode):
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r287968. rdar://problem/87256207
 
     [libpas] thread_local_cache should not be allocated in the compact heap (cherry pick 11afcedfb5968f6894379ff1a41dd449ba7745f6)

Modified: branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_local_allocator.c (289267 => 289268)


--- branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_local_allocator.c	2022-02-08 02:52:48 UTC (rev 289267)
+++ branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_local_allocator.c	2022-02-08 02:52:51 UTC (rev 289268)
@@ -180,6 +180,9 @@
     
     if (!pas_segregated_page_switch_lock_with_mode(page, &held_lock, page_lock_mode, page_config))
         return false;
+
+    if (!pas_segregated_page_config_is_utility(page_config) && !held_lock)
+        pas_panic("Should be holding a lock after pas_segregated_page_switch_lock_with_mode in stop_impl\n");
     
     page_config.specialized_local_allocator_return_memory_to_page(
         allocator, view, page, directory, heap_lock_hold_mode);

Modified: branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page.c (289267 => 289268)


--- branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page.c	2022-02-08 02:52:48 UTC (rev 289267)
+++ branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page.c	2022-02-08 02:52:51 UTC (rev 289268)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2021 Apple Inc. All rights reserved.
+ * Copyright (c) 2018-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -125,6 +125,7 @@
         bool got_right_lock;
     
         page_lock = page->lock_ptr;
+        PAS_TESTING_ASSERT(page_lock);
 
         if (*held_lock == page_lock && *held_lock == &cache_node->page_lock) {
             pas_compiler_fence();

Modified: branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page_inlines.h (289267 => 289268)


--- branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page_inlines.h	2022-02-08 02:52:48 UTC (rev 289267)
+++ branches/safari-613-branch/Source/bmalloc/libpas/src/libpas/pas_segregated_page_inlines.h	2022-02-08 02:52:51 UTC (rev 289268)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2021 Apple Inc. All rights reserved.
+ * Copyright (c) 2018-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -130,6 +130,8 @@
     pas_lock** held_lock,
     pas_lock* lock_ptr)
 {
+    PAS_TESTING_ASSERT(lock_ptr);
+    
     *held_lock = lock_ptr;
     
     if (PAS_LIKELY(pas_lock_try_lock(lock_ptr)))
@@ -151,6 +153,8 @@
         return true;
     }
 
+    PAS_TESTING_ASSERT(lock_ptr);
+
     return pas_segregated_page_lock_with_unbias_not_utility(page, held_lock, lock_ptr);
 }
 
@@ -170,7 +174,7 @@
         pas_lock* held_lock_ignored;
         
         lock_ptr = page->lock_ptr;
-        
+
         if (pas_segregated_page_lock_with_unbias(page, &held_lock_ignored, lock_ptr, page_config))
             return;
         
@@ -208,6 +212,8 @@
     
     held_lock_value = *held_lock;
     page_lock = page->lock_ptr;
+
+    PAS_TESTING_ASSERT(page_lock);
     
     if (PAS_LIKELY(held_lock_value == page_lock)) {
         if (verbose)
@@ -232,8 +238,12 @@
     }
 
     switch (lock_mode) {
-    case pas_lock_lock_mode_try_lock:
-        return pas_lock_switch_with_mode(held_lock, page->lock_ptr, pas_lock_lock_mode_try_lock);
+    case pas_lock_lock_mode_try_lock: {
+        pas_lock* page_lock;
+        page_lock = page->lock_ptr;
+        PAS_TESTING_ASSERT(page_lock);
+        return pas_lock_switch_with_mode(held_lock, page_lock, pas_lock_lock_mode_try_lock);
+    }
 
     case pas_lock_lock_mode_lock: {
         pas_segregated_page_switch_lock_impl(page, held_lock);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to