mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
Assistant: Fix crash in FileProvider background thread upon exit
If the Threading::BackgroundAction for filesystem indexing in FileProvider hadn't finished by the time the main thread exited, it would still try to access the FileProvider object that lived in the main thread, thereby causing a segfault and crashing. This commit prevents FileProvider from being destroyed while the background thread is still running by giving the background thread a strong reference to its FileProvider.
This commit is contained in:
parent
ada1d4906e
commit
a610d9a3d1
Notes:
sideshowbarker
2024-07-17 20:49:45 +09:00
Author: https://github.com/Rummskartoffel Commit: https://github.com/SerenityOS/serenity/commit/a610d9a3d1c Pull-request: https://github.com/SerenityOS/serenity/pull/11919 Issue: https://github.com/SerenityOS/serenity/issues/11766 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/awesomekling
1 changed files with 1 additions and 1 deletions
|
@ -164,7 +164,7 @@ void FileProvider::build_filesystem_cache()
|
|||
m_work_queue.enqueue("/");
|
||||
|
||||
(void)Threading::BackgroundAction<int>::construct(
|
||||
[this](auto&) {
|
||||
[this, strong_ref = NonnullRefPtr(*this)](auto&) {
|
||||
String slash = "/";
|
||||
auto timer = Core::ElapsedTimer::start_new();
|
||||
while (!m_work_queue.is_empty()) {
|
||||
|
|
Loading…
Reference in a new issue