Skip to content

GpifParser crashes on orphan tempo automations referencing missing master bars #2671

@kaizenman

Description

@kaizenman

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

GpifParser._buildModel iterates _masterTrackAutomations and dereferences score.masterBars[barNumber] without checking that the index is in range:

const masterBar: MasterBar = this.score.masterBars[barNumber];
// masterBar can be undefined when barNumber >= masterBars.length

On real-world Guitar Pro 7/8 files where the score has been edited (e.g. bars removed) without removing the corresponding <MasterTrack> automations, or in files with off-by-one bar indices, this throws and the file fails to load entirely:

TypeError: Cannot read properties of undefined (reading 'tempoAutomations')
    at GpifParser._buildModel (GpifParser.ts:2900)
    at GpifParser.parseXml (GpifParser.ts:176)
    at Gp7To8Importer.readScore (Gp7To8Importer.ts:75)

Expected Behavior

Guitar Pro desktop silently ignores orphan automations and renders the score normally. AlphaTab should match: skip the automation, continue parsing the rest of the score.

Steps To Reproduce

  1. Obtain a Guitar Pro 8 file where a <MasterTrack> <TempoAutomation> references Bar="N" for some N >= masterBars.length. Such files appear in the wild when bars are removed from the score after the automation was created.
  2. Reference fixture: test-data/guitarpro8/orphan-tempo-automation.gp (a published GP8 file with 100 master bars and tempo automations targeting bars [0, 91-95, 97-100] — automation at bar 100 is one past the end). Fixture is committed in PR fix(importer): skip GPIF tempo automations on missing master bars #2668.
  3. Run ScoreLoader.loadScoreFromBytes(bytes) (Node).
  4. Observe TypeError thrown from GpifParser._buildModel.

Link to jsFiddle, CodePen, Project

N/A — fixture committed in PR #2668 (packages/alphatab/test-data/guitarpro8/orphan-tempo-automation.gp).

Version and Environment

alphaTab: 1.9.0 (commit f8ef24f, current HEAD of `develop`)
Node.js: v22.14.0
OS: Ubuntu 22.04.3 LTS on WSL2 (kernel 6.6.87.2-microsoft-standard-WSL2)

The bug is on the importer side, so it surfaces on every platform that consumes the resulting Score — Web, Node.js, .NET, Android, iOS all affected equally. Reproducer environment above is just where I observed it.

Platform

Node.js

Anything else?

Fix proposed in PR #2668. Two related bugs from the same area (#2672, #2673) are tracked separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions