Skip to content

Wrong offset in MIDIPacketList struct #374

@davidgiga1993

Description

@davidgiga1993

Issue details

The struct definition for MIDIPacketList is wrong and only seems to work by accident on 32bit platforms.
When calling getPacket() on a MIDIPacketList struct the returned packet is off by 4 byte on a 64bit platform.

Example:
On 32bit

  • Pointer of list: 6106767000
  • Pointer of getPacket().getHandle(): 6106767004

On 64bit

  • Pointer of list: 6106767000
  • Pointer of getPacket().getHandle(): 6106767008
    Therefore all the data of the MIDIPacket is invalid on 64bit platforms.

The issue is that the packet is not referenced by ref in the original header - therefore the offset is always 4 byte (the numPackets field)

Reproduction steps/code

  • Receive midi data using CoreMidi
  • The length of any midi packet is way too long on 64bit platforms which shows the off by 4.

Configuration

Build Tools:

  • Gradle plugin

Versions:

  • Robovm: 2.3.7-SNAPSHOT
  • XCode: 10.2.1
  • JDK: 1.8.0_181

Build Targets:
iPhone 8 (64 bit)

Workaround

As of now I'm reading the packet with an hardcoded 4 byte offset but that's pretty ugly..

long listPointer = pktlist.getHandle();
MIDIPacket packet = MIDIPacket.toStruct(MIDIPacket.class, listPointer + 4);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions