Skip to content

Commit ce0104b

Browse files
Merge pull request #26404 from cbjeukendrup/crash_export_audio_asyncimpl_25884
Fix crash because of data race in `AsyncImpl::onCall`
2 parents b4cee3f + 447baec commit ce0104b

File tree

1 file changed

+8
-12
lines changed
  • src/framework/global/thirdparty/kors_async/async/internal

1 file changed

+8
-12
lines changed

src/framework/global/thirdparty/kors_async/async/internal/asyncimpl.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,13 @@ AsyncImpl* AsyncImpl::instance()
3636
void AsyncImpl::disconnectAsync(Asyncable* caller)
3737
{
3838
std::lock_guard locker(m_mutex);
39-
uint64_t key = 0;
40-
std::map<uint64_t, Call>::const_iterator it = m_calls.cbegin(), end = m_calls.cend();
41-
for (; it != end; ++it) {
39+
40+
for (auto it = m_calls.cbegin(), end = m_calls.cend(); it != end; ++it) {
4241
if (it->second.caller == caller) {
43-
key = it->first;
42+
m_calls.erase(it);
4443
break;
4544
}
4645
}
47-
48-
if (key) {
49-
m_calls.erase(key);
50-
}
5146
}
5247

5348
void AsyncImpl::call(Asyncable* caller, IFunction* f, const std::thread::id& th)
@@ -79,14 +74,15 @@ void AsyncImpl::onCall(uint64_t key)
7974
}
8075

8176
c = it->second;
77+
8278
m_calls.erase(it);
79+
80+
if (c.caller) {
81+
c.caller->disconnectAsync(this);
82+
}
8383
}
8484

8585
c.f->call();
8686

87-
if (c.caller) {
88-
c.caller->disconnectAsync(this);
89-
}
90-
9187
delete c.f;
9288
}

0 commit comments

Comments
 (0)