mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 09:56:45 +02:00
LibGC: Prune weak containers in stop-the-world phase of GC
Move weak container cleanup (remove_dead_cells) out of both sweep_dead_cells() and start_incremental_sweep() to the place where it is actually safe to inspect cell state: collect_garbage(). Previously, remove_dead_cells could access cells that had already been swept and poisoned by ASAN, causing use-after-poison crashes when a new GC triggered while an incremental sweep was in progress.
This commit is contained in:
committed by
Andreas Kling
parent
fb4095ae50
commit
245b7d74a7
Notes:
github-actions[bot]
2026-05-10 09:00:20 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/245b7d74a76 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7663 Reviewed-by: https://github.com/ADKaster
@@ -341,13 +341,16 @@ StaticPropertyLookupCache::StaticPropertyLookupCache()
|
||||
|
||||
static void clear_cache_entry_if_dead(PropertyLookupCache::Entry& entry)
|
||||
{
|
||||
if (entry.from_shape && entry.from_shape->state() != Cell::State::Live)
|
||||
auto cell_is_dead = [](Cell const* cell) {
|
||||
return cell->state() != Cell::State::Live || !cell->is_marked();
|
||||
};
|
||||
if (entry.from_shape && cell_is_dead(entry.from_shape))
|
||||
entry.from_shape = nullptr;
|
||||
if (entry.shape && entry.shape->state() != Cell::State::Live)
|
||||
if (entry.shape && cell_is_dead(entry.shape))
|
||||
entry.shape = nullptr;
|
||||
if (entry.prototype && entry.prototype->state() != Cell::State::Live)
|
||||
if (entry.prototype && cell_is_dead(entry.prototype))
|
||||
entry.prototype = nullptr;
|
||||
if (entry.prototype_chain_validity && entry.prototype_chain_validity->state() != Cell::State::Live)
|
||||
if (entry.prototype_chain_validity && cell_is_dead(entry.prototype_chain_validity))
|
||||
entry.prototype_chain_validity = nullptr;
|
||||
}
|
||||
|
||||
@@ -370,7 +373,7 @@ void Executable::remove_dead_cells(Badge<GC::Heap>)
|
||||
clear_cache_entry_if_dead(entry);
|
||||
}
|
||||
for (auto& cache : object_shape_caches) {
|
||||
if (cache.shape && cache.shape->state() != Cell::State::Live)
|
||||
if (cache.shape && (cache.shape->state() != Cell::State::Live || !cache.shape->is_marked()))
|
||||
cache.shape = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user