Skip to content

Commit 1a4a1cd

Browse files
authored
fix close deadlock (#683)
* fix close deadlock * add comment
1 parent ee428ef commit 1a4a1cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

aui.core/src/AUI/Common/ASignal.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,15 @@ class ASignal final : public AAbstractSignal {
283283
if (!value) {
284284
return;
285285
}
286-
std::unique_lock lock(AObjectBase::SIGNAL_SLOT_GLOBAL_SYNC);
287-
// this destructor can be called in ASignal destructor, so it's worth to reset the sender as well.
288-
value->sender = nullptr;
289-
value->unlinkInReceiverSideOnly(lock);
286+
{
287+
std::unique_lock lock(AObjectBase::SIGNAL_SLOT_GLOBAL_SYNC);
288+
// this destructor can be called in ASignal destructor, so it's worth to reset the sender as well.
289+
value->sender = nullptr;
290+
value->unlinkInReceiverSideOnly(lock);
291+
}
292+
// releasing lock before value = nullptr.
293+
// destroying `value` object could trigger a cascade of destructions, leading to a re-entrant lock
294+
// attempt on a non-recursive mutex.
290295
value = nullptr;
291296
}
292297
};

0 commit comments

Comments
 (0)