Skip to content

5.11.0: NPE in Voices.refineSystem (RHYTHMS) on systems with varying staff counts #970

Description

@jdburrage

Summary

On a score whose systems hold different numbers of staves — an orchestral score that
omits the staves of resting instruments — the RHYTHMS step throws
NullPointerException in Voices.refineSystem, and the affected sheets never reach PAGE.

Environment

Audiveris 5.11.0, build 9e1e55cd2746037d059345881c53e6a6754bffbd
Windows 11 10.0, amd64
OpenJDK 64-Bit Server VM (build 25.0.3+9-LTS, mixed mode)
Tesseract OCR 5.5.2

Input

Haydn, Symphony No. 45 "Farewell", Timothy Lanfear 2020 engraving, 33 pages — freely
downloadable from IMSLP as file #633504:
https://imslp.org/wiki/Symphony_No.45_in_F-sharp_minor,_Hob.I:45_(Haydn,_Joseph)

This symphony is the natural test case for varying staff counts: the finale is written so
that the players leave the stage one at a time, and this engraving prints that literally.
Page 33 alone steps 6 → 5 → 3 → 3 → 2 staves system by system.

Command

Audiveris.exe -batch -export -save -output <dir> -- IMSLP633504-PMLP51750-045-imslp.pdf

Actual

Sheets 30, 32 and 33 stop at step 18 of 20; sheet 31 at step 17. Exit code 1, and because
no sheet completes the book, Created scores: [] and no MusicXML is written at all — the
other 27 sheets, which transcribe correctly, produce nothing.

Sheets 30, 32, 33:

WARN [#30] Book.java:2044 | Error processing stub java.lang.NullPointerException:
  Cannot invoke "org.audiveris.omr.sheet.rhythm.Measure.purgeVoices()" because "measure" is null
java.util.concurrent.ExecutionException: java.lang.NullPointerException: ...
	at org.audiveris.omr.sheet.SheetStub.doOneStep(SheetStub.java:519)
	at org.audiveris.omr.sheet.SheetStub.reachStep(SheetStub.java:1405)
	at org.audiveris.omr.sheet.Book.reachBookStep(Book.java:2035)
	at org.audiveris.omr.sheet.Book.transcribe(Book.java:2626)
	at org.audiveris.omr.sheet.Book.export(Book.java:593)
	at org.audiveris.omr.CLI$ProcessingTask.processBook(CLI.java:927)
Caused by: java.lang.NullPointerException:
  Cannot invoke "org.audiveris.omr.sheet.rhythm.Measure.purgeVoices()" because "measure" is null
	at org.audiveris.omr.sheet.rhythm.Voices.refineSystem(Voices.java:430)
	at org.audiveris.omr.sheet.rhythm.PageRhythm.processRanges(PageRhythm.java:288)
	at org.audiveris.omr.sheet.rhythm.PageRhythm.process(PageRhythm.java:248)
	at org.audiveris.omr.sheet.rhythm.RhythmsStep.doit(RhythmsStep.java:192)

Sheet 31, same step, different symptom:

WARN [#31] Book.java:2044 | Error processing stub java.lang.RuntimeException:
  java.lang.IndexOutOfBoundsException: Index 8 out of bounds for length 8

Expected

Either the sheets transcribe, or they fail individually without costing the other 27
sheets their export.

Notes

Voices.refineSystem appears to assume that a measure exists at a given index in every
part of the system. Where a system omits the staves of resting instruments, the part/measure
grid is not rectangular, and the lookup returns null.

The sheets that fail are exactly the ones whose systems vary in staff count, read off
book.xml (<part> count per <system>):

sheets  3..29   mostly uniform
sheet   30      [10, 11]
sheet   31      [9, 10]
sheet   32      [6, 7]
sheet   33      [1, 3, 5, 6]

A related but distinct failure in the same area affects export even when no sheet crashes;
filed separately.

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