[jdk23] Integrated: 8336375: Crash on paste to JShell
Jan Lahoda
jlahoda at openjdk.org
Thu Jul 18 04:49:37 UTC 2024
On Wed, 17 Jul 2024 06:48:07 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> 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
This pull request has now been integrated.
Changeset: 0c82e4bf
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/0c82e4bf19ab608406190429b6b55c54b299d962
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
8336375: Crash on paste to JShell
Reviewed-by: jvernee
Backport-of: b9b0b8504ec989ad0687188de4bccfe2c04e5d64
-------------
PR: https://git.openjdk.org/jdk/pull/20213
More information about the kulla-dev
mailing list