Bug 166875 - Inspect and sanitize implementations of XEventListener::disposing, to avoid calling the disposing broadcaster's methods
Summary: Inspect and sanitize implementations of XEventListener::disposing, to avoid c...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks:
 
Reported: 2025-06-06 09:04 UTC by Mike Kaganski
Modified: 2025-06-07 09:47 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2025-06-06 09:04:01 UTC
XEventListener::disposing is documented [1] with an explicit requirement, that from this point on, no methods of the source of the disposing notification (the broadcaster) must be called, not even to remove the listener from the broadcaster.

However, in some places, the actual implementations of the disposing() method do that - try to remove itself from the caller (directly or indirectly (using methods that themselves do that); referencing the broadcaster using the passed argument, or by a reference stored in this listener).

In severe cases, this could crash. Sometimes that works in release, but asserts in debug builds. In any way, that is incorrect.

The only thing that must be done in this method regarding the broadcaster, is to clear all own references to it, not to call it.

This easyhack is about finding the implementations of XEventListener::disposing in the codebase, and auditing them to make sure that they comply with the requirement.

[1] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XEventListener.html#aae6e796f0b3b6a2dba2c1a6bda1a10a1
Comment 1 Commit Notification 2025-06-07 09:47:00 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/af8c52479064a72623f2d8eb9f479b741a2c735c

tdf#166875: Don't notify broadcaster from its disposing notification

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.