Tk Source Code

View Ticket
Login
Ticket UUID: 8369db351baa9f1efdbad7a2316ff8bc0311e1d6
Title: Aqua: undefined behavior in GenerateUpdates()
Type: Bug Version: core-9-0-branch
Submitter: chrstphrchvz Created on: 2025-08-31 03:40:50
Subsystem: 99. Other Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-10-27 13:43:23
Resolution: None Closed By: nobody
    Closed on:
Description:

At the beginning of GenerateUpdates() (tkMacOSXWindowEvent.c:578) there is this code that has been disabled since [4cfef4ba]:

#if 0
    if (!CGRectIntersectsRect(bounds, *updateBounds)) {
	return 0;
    }
#endif

I do not think it needs to be re-enabled, but something that is now possible is that damageBounds can be a null rectangle (represented by {{inf, inf}, {0, 0}}) if a widget window is outside the viewable portion of a toplevel, which poses an issue for these lines:

    event.xexpose.x = damageBounds.origin.x - bounds.origin.x;
    event.xexpose.y = damageBounds.origin.y - bounds.origin.y;

Example UBSan errors:

tkMacOSXWindowEvent.c:594:23: runtime error: inf is outside the range of representable values of type 'int'
tkMacOSXWindowEvent.c:595:23: runtime error: inf is outside the range of representable values of type 'int'

Currently I would suggest only sending an Expose event when CGRectIsNull(damageBounds) is false to avoid this issue; see branch bug-8369db35.