mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 16:44:58 +00:00
LibWeb: Queue a task to proceed after module map entry finishes fetching
We were doing this synchronously, which was unsafe in that caused us to re-enter the module map entry setting code while iterating over the map's entries. The fix is simply to do what the spec says and queue up a task. This way the processing gets deferred to a later time. To avoid stepping into this problem again, I've also added a reentrancy check in ModuleMap. This fixes a sporadic crash in HTML::ModuleMap::add() caught by ASAN. In particular, this was happening regularly on https://shopify.com/
This commit is contained in:
parent
2753075830
commit
e28ac74e0b
3 changed files with 15 additions and 7 deletions
|
@ -47,12 +47,18 @@ Optional<ModuleMap::Entry> ModuleMap::get(AK::URL const& url, DeprecatedString c
|
|||
|
||||
AK::HashSetResult ModuleMap::set(AK::URL const& url, DeprecatedString const& type, Entry entry)
|
||||
{
|
||||
// NOTE: Re-entering this function while firing wait_for_change callbacks is not allowed.
|
||||
VERIFY(!m_firing_callbacks);
|
||||
|
||||
auto value = m_values.set({ url, type }, entry);
|
||||
|
||||
auto callbacks = m_callbacks.get({ url, type });
|
||||
if (callbacks.has_value())
|
||||
if (callbacks.has_value()) {
|
||||
m_firing_callbacks = true;
|
||||
for (auto const& callback : *callbacks)
|
||||
callback->function()(entry);
|
||||
m_firing_callbacks = false;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue