On Tue, 17 Mar 2026 20:10:52 GMT, Alexander Zuev <[email protected]> wrote:

> Add lifecycle control to the semaphore.

I'm not sure how this code path gets executed. It would be nice to have some 
description in either the PR or original bug report.

modules/javafx.graphics/src/main/native-glass/mac/GlassApplication.m line 1364:

> 1362:     dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 
> (int64_t)(NSEC_PER_SEC)); // 1 second timeout
> 1363: 
> 1364:     dispatch_retain(semaphore);

This fix looks incorrect. When the semaphore is created it will have a retain 
count of 1. This line bumps the retain count to two. After 
dispatch_semaphore_signal the semaphore is released and the retain count will 
go back to 1. So the leak will still be present.

The pattern used in AWT is to call dispatch_retain once and dispatch_release 
twice, once after dispatch_semaphore_signal and again after 
dispatch_semaphore_wait. That's a bit excessive (all one really needs is a 
single call to dispatch_release after dispatch_semaphore_wait) but it's 
probably not a bad idea to follow AWT's lead here.

-------------

Changes requested by mfox (Committer).

PR Review: https://git.openjdk.org/jfx/pull/2110#pullrequestreview-3986999412
PR Review Comment: https://git.openjdk.org/jfx/pull/2110#discussion_r2970407714

Reply via email to