Skip to content

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

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

No response

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)

Platform

Web

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-file-formatsRelated to supported file formatsplatform-allAffects all platformsstate-acceptedThis is a valid topic to work on.

Type

Fields

Priority

None yet

Effort

None yet

Area

None yet

Platform

None yet

Work State

None yet

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions