Integrated: 8269630: Bad clipboard data causes JVM to crash
Lukasz Kostyra
lkostyra at openjdk.org
Wed Jan 7 07:13:58 UTC 2026
On Fri, 5 Dec 2025 13:43:45 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:
> This commit fixes the JVM crash caused by bad Clipboard data on Linux.
>
> On Windows the Clipboard is a bit more generic in how it operates - even if the MIME type mismatches, the Clipboard will accept any object and then return it. GTK is less generic in this regard (at least our Glass implementation) so for cases like text it requires us to fetch the String contents and set those directly onto the Clipboard.
>
> Moreover, `ClipboardContent` is simply an extension of `HashMap` which exposes `put()` and lets us assign whatever object we want to whatever MIME type we want. As such, if we follow the example code from the JDK issue, we would try to fetch String contents from something that is not a String, causing SIGSEGV.
>
> Fix was done by type-checking incoming `ClipboardContent` data. I saw that this can also happen in other content types than text, so I guarded those as well. If types are not what we expect them to be, the attempt to update the System Clipboard is silently discarded and the crash is avoided. According to my manual testing, as long as data types are correct everything seems to work fine.
>
> As a side-note, this also shows there is discrepancy in how `Clipboard` operates between platforms. We should unify that behavior, but that is a larger task which will be solved under [JDK-8373090](https://bugs.openjdk.org/browse/JDK-8373090).
This pull request has now been integrated.
Changeset: cfa34e61
Author: Lukasz Kostyra <lkostyra at openjdk.org>
URL: https://git.openjdk.org/jfx/commit/cfa34e61534c71442591f011c921b62efedbfadd
Stats: 15 lines in 1 file changed: 6 ins; 0 del; 9 mod
8269630: Bad clipboard data causes JVM to crash
Reviewed-by: arapte, kcr
-------------
PR: https://git.openjdk.org/jfx/pull/1999
More information about the openjfx-dev
mailing list