Changeset 287991 in webkit


Ignore:
Timestamp:
Jan 13, 2022 1:12:09 PM (2 years ago)
Author:
fpizlo@apple.com
Message:

[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):

Location:
trunk/Source/bmalloc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r287968 r287991  
     12022-01-13  Filip Pizlo  <fpizlo@apple.com>
     2
     3        [libpas] add assertions that we aren't switching to a NULL lock
     4        https://bugs.webkit.org/show_bug.cgi?id=235190
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This adds a pas_panic call when pas_local_allocator_stop sees a NULL page->lock_ptr. That's one
     9        possible explanation of a very rare crash I'm seeing where return_memory_to_page fails its assertion
     10        that we are holding the page lock.
     11
     12        This also adds TESTING asserts in a bunch of other places. The PAS_TESTING_ASSERTS about this are in
     13        places that are perf-sensitive, so we probably cannot assert in production. The hope behind those is
     14        that it will help to catch this issue in test_pas.
     15
     16        * libpas/src/libpas/pas_local_allocator.c:
     17        (stop_impl):
     18        * libpas/src/libpas/pas_segregated_page.c:
     19        (pas_segregated_page_switch_lock_and_rebias_while_ineligible_impl):
     20        * libpas/src/libpas/pas_segregated_page_inlines.h:
     21        (pas_segregated_page_lock_with_unbias_not_utility):
     22        (pas_segregated_page_lock_with_unbias):
     23        (pas_segregated_page_lock):
     24        (pas_segregated_page_switch_lock_impl):
     25        (pas_segregated_page_switch_lock_with_mode):
     26
    1272022-01-12  Filip Pizlo  <fpizlo@apple.com>
    228
  • trunk/Source/bmalloc/libpas/src/libpas/pas_local_allocator.c

    r287968 r287991  
    181181    if (!pas_segregated_page_switch_lock_with_mode(page, &held_lock, page_lock_mode, page_config))
    182182        return false;
     183
     184    if (!pas_segregated_page_config_is_utility(page_config) && !held_lock)
     185        pas_panic("Should be holding a lock after pas_segregated_page_switch_lock_with_mode in stop_impl\n");
    183186   
    184187    page_config.specialized_local_allocator_return_memory_to_page(
  • trunk/Source/bmalloc/libpas/src/libpas/pas_segregated_page.c

    r287192 r287991  
    11/*
    2  * Copyright (c) 2018-2021 Apple Inc. All rights reserved.
     2 * Copyright (c) 2018-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    126126   
    127127        page_lock = page->lock_ptr;
     128        PAS_TESTING_ASSERT(page_lock);
    128129
    129130        if (*held_lock == page_lock && *held_lock == &cache_node->page_lock) {
  • trunk/Source/bmalloc/libpas/src/libpas/pas_segregated_page_inlines.h

    r287192 r287991  
    11/*
    2  * Copyright (c) 2018-2021 Apple Inc. All rights reserved.
     2 * Copyright (c) 2018-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    131131    pas_lock* lock_ptr)
    132132{
     133    PAS_TESTING_ASSERT(lock_ptr);
     134   
    133135    *held_lock = lock_ptr;
    134136   
     
    152154    }
    153155
     156    PAS_TESTING_ASSERT(lock_ptr);
     157
    154158    return pas_segregated_page_lock_with_unbias_not_utility(page, held_lock, lock_ptr);
    155159}
     
    171175       
    172176        lock_ptr = page->lock_ptr;
    173        
     177
    174178        if (pas_segregated_page_lock_with_unbias(page, &held_lock_ignored, lock_ptr, page_config))
    175179            return;
     
    209213    held_lock_value = *held_lock;
    210214    page_lock = page->lock_ptr;
     215
     216    PAS_TESTING_ASSERT(page_lock);
    211217   
    212218    if (PAS_LIKELY(held_lock_value == page_lock)) {
     
    233239
    234240    switch (lock_mode) {
    235     case pas_lock_lock_mode_try_lock:
    236         return pas_lock_switch_with_mode(held_lock, page->lock_ptr, pas_lock_lock_mode_try_lock);
     241    case pas_lock_lock_mode_try_lock: {
     242        pas_lock* page_lock;
     243        page_lock = page->lock_ptr;
     244        PAS_TESTING_ASSERT(page_lock);
     245        return pas_lock_switch_with_mode(held_lock, page_lock, pas_lock_lock_mode_try_lock);
     246    }
    237247
    238248    case pas_lock_lock_mode_lock: {
Note: See TracChangeset for help on using the changeset viewer.