[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    RFR: 8322215: [win] OS events that close the stage can cause Glass to reference freed memory
From:       Martin Fox <mfox () openjdk ! org>
Date:       2023-12-20 17:35:58
Message-ID: nMW-KMWLPLyjY2koVPx5tyk4YSnrJ7iB13Luj58m8JY=.85bce910-5396-4755-858e-07d37cd923dc () github ! com
[Download RAW message or body]

When a Stage is closed while processing an OS message the glass peer object is \
deleted immediately even if it's still executing member functions. As glass unwinds \
the stack and executes cleanup code it's referencing freed memory.

There are cases where glass generates JavaFX events back-to-back. For example, when \
handling the Delete key glass sends a PRESSED and TYPED event in the same routine. If \
the Stage is closed during the PRESSED event the code that sends the TYPED event is \
running inside an object that has already been deleted.

When the Stage is closed glass calls the OS routine ::DestroyWindow on the HWND \
causing a WM_NCDESTROY message to be sent. Currently the BaseWnd object is deleted \
when processing this message. This PR defers the destruction until all messages have \
been processed. This is the same approach used in the Linux code.

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

Commit messages:
 - Window context is only deleted after all messages are processed

Changes: https://git.openjdk.org/jfx/pull/1309/files
 Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1309&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322215
  Stats: 32 lines in 2 files changed: 30 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jfx/pull/1309.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1309/head:pull/1309

PR: https://git.openjdk.org/jfx/pull/1309


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic