Skip to content

fix(AbstractEvent): operator-= holds the event mutex across Delegate:…#5358

Merged
matejk merged 3 commits into
mainfrom
5357-event-lock-order
May 19, 2026
Merged

fix(AbstractEvent): operator-= holds the event mutex across Delegate:…#5358
matejk merged 3 commits into
mainfrom
5357-event-lock-order

Conversation

@aleks-f
Copy link
Copy Markdown
Member

@aleks-f aleks-f commented May 18, 2026

…:disable #5357

@aleks-f aleks-f added this to the Release 1.15.3 milestone May 18, 2026
@aleks-f aleks-f requested review from Copilot and matejk May 18, 2026 18:08
@aleks-f aleks-f added the bug label May 18, 2026
CoreTest::testEnvironmentMultiThread captured const int locals
(iterations, numWriters) and an unused id in the reader lambda.
Clang flagged the const captures as not required and the id capture
as unused. Remove them; the lambda bodies still resolve those names
from the enclosing scope without explicit capture.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates event delegate removal/clear to avoid holding the event mutex while disabling delegates (addressing a TSAN-reported lock-order cycle), and adds a targeted test case.

Changes:

  • Refactors AbstractEvent::operator-= and AbstractEvent::clear() to detach delegates under the event mutex and call disable() after releasing it.
  • Extends notification strategies (DefaultStrategy, PriorityStrategy) with detach* helpers to support the new lock-breaking behavior.
  • Adds a new BasicEventTest covering delegate removal during notify(); adjusts an environment multithread test (but introduces a capture mismatch).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Foundation/testsuite/src/CoreTest.cpp Adjusts thread lambda capture lists in testEnvironmentMultiThread() (currently breaks compilation).
Foundation/testsuite/src/BasicEventTest.h Declares new test testRemoveDelegateFromNotify().
Foundation/testsuite/src/BasicEventTest.cpp Adds cross-removal helper and new test documenting/targeting the lock-order cycle.
Foundation/include/Poco/PriorityStrategy.h Adds detach, detachAll and updates remove/clear to disable after detaching.
Foundation/include/Poco/DefaultStrategy.h Adds documented detach, detachAll and updates remove/clear similarly.
Foundation/include/Poco/AbstractEvent.h Uses detach/detachAll so disable() runs outside the event mutex.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Foundation/testsuite/src/CoreTest.cpp
Comment thread Foundation/testsuite/src/CoreTest.cpp
Comment thread Foundation/include/Poco/AbstractEvent.h
Comment thread Foundation/testsuite/src/BasicEventTest.cpp
…5358

AbstractEvent's lock-order fix calls _strategy.detach() and uses
TStrategy::DelegatePtr, which were not part of the documented
NotificationStrategy interface. Custom downstream strategies would
fail with a confusing per-call-site error instead of an interface
mismatch. Promote detach/detachAll and the DelegatePtr/Delegates
typedefs to NotificationStrategy as pure virtual to make the new
requirement explicit. In-tree strategies (DefaultStrategy,
PriorityStrategy, FIFOStrategy) already implement them.

Also strengthen testRemoveDelegateFromNotify with assertEqual(0,
b.fired()) so the documented behaviour (delegate removed during
notify is not invoked later in the same sequence) is validated
even without TSAN.
@matejk matejk merged commit a8fdb2b into main May 19, 2026
52 checks passed
matejk pushed a commit that referenced this pull request May 20, 2026
#5358)

* fix(AbstractEvent): operator-= holds the event mutex across Delegate::disable #5357

* chore(test): drop redundant lambda captures in CoreTest

CoreTest::testEnvironmentMultiThread captured const int locals
(iterations, numWriters) and an unused id in the reader lambda.
Clang flagged the const captures as not required and the id capture
as unused. Remove them; the lambda bodies still resolve those names
from the enclosing scope without explicit capture.

* fix(Foundation): add detach/detachAll to NotificationStrategy concept #5358

AbstractEvent's lock-order fix calls _strategy.detach() and uses
TStrategy::DelegatePtr, which were not part of the documented
NotificationStrategy interface. Custom downstream strategies would
fail with a confusing per-call-site error instead of an interface
mismatch. Promote detach/detachAll and the DelegatePtr/Delegates
typedefs to NotificationStrategy as pure virtual to make the new
requirement explicit. In-tree strategies (DefaultStrategy,
PriorityStrategy, FIFOStrategy) already implement them.

Also strengthen testRemoveDelegateFromNotify with assertEqual(0,
b.fired()) so the documented behaviour (delegate removed during
notify is not invoked later in the same sequence) is validated
even without TSAN.
matejk added a commit that referenced this pull request May 20, 2026
Four PRs merged on main after the release commit and cherry-picked
into poco-1.15.3:

- #5358 fix(AbstractEvent): operator-= holds the event mutex across
  Delegate destructor
- #5359 enh(MongoDB): MongoDB 6.0/7.0/8.0 compat (carries its own
  API Changes block for SCRAM-SHA-256 default, count() via $count,
  deprecated INDEX_BACKGROUND / CMD_MAP_REDUCE)
- #5355 (GH #5354) feat(CppUnit): terminate handler
- #5356 fix(Foundation): gate atomic_flag::test on C++20 atomic_wait

Also tighten the Summary paragraph to call out the MongoDB compat
work and add the MongoDB API Changes to doc/99100-ReleaseNotes.page
to match CHANGELOG. CONTRIBUTORS unchanged -- all four PR authors
(aleks-f, uilianries, matejk) are already listed.
matejk added a commit that referenced this pull request May 20, 2026
…5.3 overview

Four PRs merged on main after the release commit and cherry-picked
into poco-1.15.3:

- #5358 fix(AbstractEvent): operator-= holds the event mutex across
  Delegate destructor
- #5359 enh(MongoDB): MongoDB 6.0/7.0/8.0 compat (carries its own
  API Changes for SCRAM-SHA-256 default, count() via $count,
  deprecated INDEX_BACKGROUND / CMD_MAP_REDUCE)
- #5355 (GH #5354) feat(CppUnit): terminate handler
- #5356 fix(Foundation): gate atomic_flag::test on C++20 atomic_wait

Also tighten the 1.15.3 entries: trim the Summary paragraph, replace
multi-paragraph API Changes prose with one-line bullets, drop
redundant qualifiers from bug-fix / enhancement bullets, and use the
verbatim GitHub issue/PR titles for each item. CHANGELOG and
doc/99100-ReleaseNotes.page now carry the same content. CONTRIBUTORS
unchanged -- all four PR authors (aleks-f, uilianries, matejk) are
already listed.
matejk added a commit that referenced this pull request May 20, 2026
…5.3 overview

Four PRs merged on main after the release commit and cherry-picked
into poco-1.15.3:

- #5358 fix(AbstractEvent): operator-= holds the event mutex across
  Delegate destructor
- #5359 enh(MongoDB): MongoDB 6.0/7.0/8.0 compat (carries its own
  API Changes for SCRAM-SHA-256 default, count() via $count,
  deprecated INDEX_BACKGROUND / CMD_MAP_REDUCE)
- #5355 (GH #5354) feat(CppUnit): terminate handler
- #5356 fix(Foundation): gate atomic_flag::test on C++20 atomic_wait

Also tighten the 1.15.3 entries: trim the Summary paragraph, replace
multi-paragraph API Changes prose with one-line bullets, drop
redundant qualifiers from bug-fix / enhancement bullets, and use the
verbatim GitHub issue/PR titles for each item. CHANGELOG and
doc/99100-ReleaseNotes.page now carry the same content. CONTRIBUTORS
unchanged -- all four PR authors (aleks-f, uilianries, matejk) are
already listed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AbstractEvent::operator-= holds the event mutex across Delegate::disable

3 participants