Skip to content

Commit

Permalink
8301310: The SendRawSysexMessage test may cause a JVM crash
Browse files Browse the repository at this point in the history
Reviewed-by: serb
  • Loading branch information
AlecJY authored and mrserb committed Nov 14, 2023
1 parent 12fce4b commit d725b73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/java.desktop/share/native/libjsound/MidiOutDevice.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -121,6 +121,7 @@ Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage(JNIEnv* e, jobject thisO
jbyteArray jData, jint size, jlong timeStamp) {
#if USE_PLATFORM_MIDI_OUT == TRUE
UBYTE* data;
UBYTE* msg;
#endif

TRACE0("Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage.\n");
Expand All @@ -133,11 +134,12 @@ Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage(JNIEnv* e, jobject thisO
}
/* "continuation" sysex messages start with F7 (instead of F0), but
are sent without the F7. */
msg = data;
if (data[0] == 0xF7 && size > 1) {
data++;
msg++;
size--;
}
MIDI_OUT_SendLongMessage((MidiDeviceHandle*) (UINT_PTR) deviceHandle, data,
MIDI_OUT_SendLongMessage((MidiDeviceHandle*) (UINT_PTR) deviceHandle, msg,
(UINT32) size, (UINT32)timeStamp);
// release the byte array
(*e)->ReleaseByteArrayElements(e, jData, (jbyte*) data, JNI_ABORT);
Expand Down
17 changes: 14 additions & 3 deletions test/jdk/javax/sound/midi/SysexMessage/SendRawSysexMessage.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,8 +34,9 @@

/**
* @test
* @bug 8237495
* @summary fail with a dereferenced memory error when asked to send a raw 0xF7
* @bug 8237495 8301310
* @summary fail with memory errors when asked to send a sysex message starting
* with 0xF7
*/
public final class SendRawSysexMessage {

Expand Down Expand Up @@ -113,6 +114,16 @@ private static void test(MidiDevice.Info info) throws Exception {
(byte) SPECIAL_SYSTEM_EXCLUSIVE}), -1);
System.err.println("note off");
r.send(new ShortMessage(ShortMessage.NOTE_OFF, 5, 5), -1);
System.err.println("sysex part 1 of 3");
r.send(new SysexMessage(new byte[]{
(byte) SYSTEM_EXCLUSIVE, 0x7D, 0x01, 0x02}, 4), -1);
System.err.println("sysex part 2 of 3");
r.send(new SysexMessage(new byte[]{
(byte) SPECIAL_SYSTEM_EXCLUSIVE, 0x03, 0x04}, 3), -1);
System.err.println("sysex part 3 of 3");
r.send(new SysexMessage(new byte[]{
(byte) SPECIAL_SYSTEM_EXCLUSIVE, 0x05, 0x06, 0x07,
(byte) SPECIAL_SYSTEM_EXCLUSIVE}, 4), -1);
System.err.println("done, should quit");
System.err.println();
}
Expand Down

8 comments on commit d725b73

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb
Copy link
Member

@mrserb mrserb commented on d725b73 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@mrserb
Copy link
Member

@mrserb mrserb commented on d725b73 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d725b73 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-d725b73d in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d725b73d from the openjdk/jdk repository.

The commit being backported was authored by Alec Su on 14 Nov 2023 and was reviewed by Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git mrserb-backport-d725b73d:mrserb-backport-d725b73d
$ git checkout mrserb-backport-d725b73d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git mrserb-backport-d725b73d

@openjdk
Copy link

@openjdk openjdk bot commented on d725b73 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-d725b73d in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d725b73d from the openjdk/jdk repository.

The commit being backported was authored by Alec Su on 14 Nov 2023 and was reviewed by Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git mrserb-backport-d725b73d:mrserb-backport-d725b73d
$ git checkout mrserb-backport-d725b73d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git mrserb-backport-d725b73d

@mrserb
Copy link
Member

@mrserb mrserb commented on d725b73 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@mrserb
Copy link
Member

@mrserb mrserb commented on d725b73 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d725b73 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch backport-mrserb-d725b73d in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d725b73d from the openjdk/jdk repository.

The commit being backported was authored by Alec Su on 14 Nov 2023 and was reviewed by Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-mrserb-d725b73d:backport-mrserb-d725b73d
$ git checkout backport-mrserb-d725b73d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-mrserb-d725b73d

Please sign in to comment.