Tk Source Code

View Ticket
Login
2023-07-09
17:39 Ticket [df57db0b66] SetCGColorComponents(): NSAutoreleasePool not always drained? status still Closed with 6 other changes artifact: 35b1335a9d user: fvogel
17:38 Closed ticket [a526d42999]: Aqua: fix leak in TkpOpenDisplay() plus 7 other changes artifact: 98e73d13c2 user: fvogel
17:36
Fix [a526d42999]: Aqua: leak in TkpOpenDisplay(). Patch from Christopher Chavez. check-in: 9506082b58 user: fvogel tags: trunk, main
17:23
Fix [a526d42999]: Aqua: leak in TkpOpenDisplay(). Patch from Christopher Chavez. check-in: 270db3cca1 user: fvogel tags: core-8-6-branch
04:44 Ticket [a526d42999] Aqua: fix leak in TkpOpenDisplay() status still Open with 3 other changes artifact: 2c60b77987 user: chrstphrchvz
2023-07-07
20:27 Ticket [a526d42999]: 5 changes artifact: a498c7ea44 user: chrstphrchvz
2023-04-04
01:27 Add attachment a526d4299953.diff to ticket [a526d42999] artifact: 28ab76802f user: chrstphrchvz
01:23 New ticket [a526d42999] Aqua: avoid TkpOpenDisplay() returning without draining NSAutoreleasePool. artifact: 0596d19efe user: chrstphrchvz

Ticket UUID: a526d4299953e61af10f6ca402e763c8a7bc6766
Title: Aqua: fix leak in TkpOpenDisplay()
Type: Patch Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2023-04-04 01:23:45
Subsystem: 82. X11 Emulation Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-07-09 17:38:18
Resolution: Fixed Closed By: fvogel
    Closed on: 2023-07-09 17:38:18
Description:

See attached patch. I do not know if the current code actually causes issues though.

User Comments: fvogel added on 2023-07-09 17:38:18:

Thank you. I have applied your patch to both core-8-6-branch and trunk, and have applied the principle to [df57db0b66] indeed.

Thanks!


chrstphrchvz added on 2023-07-09 04:44:07:

This explanation would also have applied to [df57db0b66].


chrstphrchvz added on 2023-07-07 20:27:27:

It seems the only way to make TkpOpenDisplay() return NULL early is to use e.g. catch {toplevel .t -screen bogus}. There seems to be no way to return gMacDisplay early since TkpOpenDisplay() is called only once per process per valid display name.

If a new pool is pushed to the stack of autorelease pools but not drained before the enclosing pool is drained, then that should behave the same as if the new pool was never pushed. And when TkpOpenDisplay() returns early, no additional objects are autoreleased.

So the only thing the patch does is avoid the NSAutoreleasePool object being leaked when the function returns early, as shown by the leaks command:

 1 (48 bytes) ROOT LEAK: <NSAutoreleasePool 0x600001a203f0> [48]


Attachments: