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:
Andreas Kling 2023-12-16 18:32:01 +01:00
parent 2753075830
commit e28ac74e0b
Notes: sideshowbarker 2024-07-16 23:55:09 +09:00
3 changed files with 15 additions and 7 deletions

View file

@ -72,6 +72,8 @@ private:
HashMap<ModuleLocationTuple, Entry> m_values;
HashMap<ModuleLocationTuple, Vector<CallbackFunction>> m_callbacks;
bool m_firing_callbacks { false };
};
}