I've applied your patch and did some testings. It indeed solves the code given with boom.ly at https://sourceforge.net/p/testlilyissues/issues/5801/
Though, I posted two minimals there. While the first one now compiles fine, the second still crashes with: GNU LilyPond 2.21.0 Processing `atest-99.ly' Parsing... Interpreting music...[8][16][24][24] Preprocessing graphical objects... Calculating page and line breaks (1 possible page breaks)...[1] Drawing systems... Layout output to `/tmp/lilypond-n0vRDz'... Converting to `atest-99.pdf'... Deleting `/tmp/lilypond-n0vRDz'... Interpreting music... Preprocessing graphical objects...lilypond: /home/hermann/lilypond-git-guile-2.2/lily/constrained-breaking.cc:481: void Constrained_breaking::initialize(Paper_score*, const std::vector<long unsigned int>&): Assertion `pagebreak_col_indices[i] > pagebreak_col_indices[i - 1]' failed. Aborted (core dumped) Probably https://sourceforge.net/p/testlilyissues/issues/5767/ is related as well. https://codereview.appspot.com/581720054/