[jdk23] RFR: 8336375: Crash on paste to JShell
Jan Lahoda
jlahoda at openjdk.org
Wed Jul 17 06:53:59 UTC 2024
Hi all,
This pull request contains a backport of commit [b9b0b850](https://github.com/openjdk/jdk/commit/b9b0b8504ec989ad0687188de4bccfe2c04e5d64) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository.
The commit being backported was authored by Jan Lahoda on 17 Jul 2024 and was reviewed by Jorn Vernee.
Thanks!
Original description:
On Windows, the `ScrollConsoleScreenBufferW` function is being looked like this:
https://github.com/openjdk/jdk/blob/a253e0ff4b88541d01596b0e73ede4b96a258fca/src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/ffm/Kernel32.java#L406
I.e. the parameters are `MemorySegment`s/pointers. But, it is being invoked like this:
https://github.com/openjdk/jdk/blob/a253e0ff4b88541d01596b0e73ede4b96a258fca/src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/ffm/Kernel32.java#L239
I.e. with values rather than with pointers. This then fails at runtime when the function is called with an exception like:
Caused by: java.lang.invoke.WrongMethodTypeException: handle's method type (MemorySegment,MemorySegment,MemorySegment,MemorySegment,MemorySegment)int but found (MemorySegment,SMALL_RECT,SMALL_RECT,COORD,CHAR_INFO)int
at java.base/java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:521)
at java.base/java.lang.invoke.Invokers.checkExactType(Invokers.java:530)
at jdk.internal.le/jdk.internal.org.jline.terminal.impl.ffm.Kernel32.ScrollConsoleScreenBuffer(Kernel32.java:239)
The proposal here is to use MemorySegments embedded in the provided parameters. This is consistent with the rest of the file, see for example here:
https://github.com/openjdk/jdk/blob/a253e0ff4b88541d01596b0e73ede4b96a258fca/src/jdk.internal.le/share/classes/jdk/internal/org/jline/terminal/impl/ffm/Kernel32.java#L173
-------------
Commit messages:
- Backport b9b0b8504ec989ad0687188de4bccfe2c04e5d64
Changes: https://git.openjdk.org/jdk/pull/20213/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20213&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8336375
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/20213.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20213/head:pull/20213
PR: https://git.openjdk.org/jdk/pull/20213
More information about the kulla-dev
mailing list