Menu

#5964 Multi_measure_rest_engraver segfaults when its context doesn’t include Staff_symbol_engraver.

Started
None
review
2020-05-09
2020-05-06
No

https://codereview.appspot.com/576090043

This used to work as recently as 2.20.0, and it no longer does:

\version 2.21.1
\layout {
  \context {
    \type Engraver_group
    \name GlobalRests
    %\consists Staff_symbol_engraver
    %\omit StaffSymbol
    \consists Multi_measure_rest_engraver
  }
  \context {
    \Score
    \accepts GlobalRests
  }
}
\score {
    \new GlobalRests { R1 }
}

Uncommenting the Staff_symbol_engraver prevents the segfault from happening.
Here’s what gdb has to say:

Program received signal SIGSEGV, Segmentation fault.
Grob::internal_get_property (this=this@entry=0x0, sym=0x7fffe98e1ea0) at grob-property.cc:162
162   SCM val = get_property_data (this, sym);

Reported by Trevor B: https://lists.gnu.org/archive/html/lilypond-user/2020-05/msg00077.html

Discussion

  • David Kastrup

    David Kastrup - 2020-05-06

    gdb would likely have a lot more to say if you told it

    bt
    

    in order to get a backtrace. This only tells us that a property access on a non-existent grob goes wrong, but not where that property is getting accessed and, likely, what the property is.

     
    • Valentin Villenave

      Duh.

      #0  Grob::internal_get_property(scm_unused_struct*) const (this=this@entry=0x0, sym=0x7fffe98e1ea0) at grob-property.cc:162
      #1  0x0000000000595190 in Staff_symbol::line_positions(Grob*) (me=0x0) at staff-symbol.cc:113
      #2  0x00000000005335d7 in Multi_measure_rest::church_rest(Grob*, Font_metric*, int, int, double) (me=me@entry=0xbaa270, musfont=musfont@entry=0xba0850, measure_count=measure_count@entry=1, mdl=<optimized out>, space=space@entry=0) at multi-measure-rest.cc:268
      #3  0x0000000000533f65 in Multi_measure_rest::symbol_stencil(Grob*, double) (me=me@entry=0xbaa270, space=space@entry=0) at multi-measure-rest.cc:216
      #4  0x000000000053487a in Multi_measure_rest::set_spacing_rods(scm_unused_struct*) (smob=<optimized out>) at multi-measure-rest.cc:417
      #5  0x00007ffff7dc1044 in scm_dapply (proc=0x7fffea23aa30, arg1=0x7fffe64ca090, args=0x404) at eval.c:4895
      #6  0x000000000065944c in Grob::try_callback_on_alist(scm_unused_struct**, scm_unused_struct*, scm_unused_struct*) (this=this@entry=0xbaa270, alist=alist@entry=0xbaa2f8, sym=0x7fffe98d1760, proc=0x7fffea23aa30) at /home/work/lilypond/lily/include/smobs.hh:318
      #7  0x000000000065967c in Grob::internal_get_property(scm_unused_struct*) const (this=this@entry=0xbaa270, sym=<optimized out>) at grob-property.cc:184
      #8  0x00000000005f8b53 in System::pre_processing() (this=0xba05d0) at system.cc:552
      #9  0x00000000006b4bf0 in ly_format_output(scm_unused_struct*) (context=context@entry=0x7fffe6529860) at global-context-scheme.cc:45
      #10 0x000000000045adc7 in Score::book_rendering(Output_def*, Output_def*) (this=this@entry=0xb76390, layoutbook=0xb76d70, default_def=default_def@entry=0xb75750) at score.cc:141
      #11 0x00000000006dbf38 in Book::process_score(scm_unused_struct*, Paper_book*, Output_def*) (this=this@entry=0xb76cf0, s=s@entry=0x7fffe6560b90, output_paper_book=output_paper_book@entry=0xb768f0, layout=layout@entry=0xb75750) at book.cc:222
      #12 0x00000000006dc7c8 in Book::process(Output_def*, Output_def*, Paper_book*) (this=this@entry=0xb76cf0, default_paper=<optimized out>, default_layout=0xb75750, parent_part=parent_part@entry=0x0) at book.cc:305
      #13 0x00000000006dc827 in Book::process(Output_def*, Output_def*) (this=this@entry=0xb76cf0, default_paper=<optimized out>, default_layout=<optimized out>) at book.cc:194
      #14 0x00000000005c9081 in ly_book_process(scm_unused_struct*, scm_unused_struct*, scm_unused_struct*, scm_unused_struct*) (book_smob=<optimized out>, default_paper=0x7fffe6882220, default_layout=0x7fffe66cba10, output=0x7fffe9556f00)
          at /home/work/lilypond/lily/include/smobs.hh:179
      #15 0x00007ffff7dc11a0 in scm_dapply (proc=0x7fffe99104f0, arg1=0x7fffea2a8ae0, args=0x7fffe65a1f80, args@entry=0x404) at eval.c:4930
      #16 0x00007ffff7dc3d41 in deval (x=<optimized out>, env=<optimized out>) at eval.c:4378
      #17 0x00007ffff7dcbf38 in scm_c_with_fluid (fluid=0x7fffe98d0300, value=value@entry=0x7fffe65a4990, cproc=cproc@entry=0x44dc40 <evaluate_scheme_form_void(void*)>, cdata=cdata@entry=0x7fffffffa4e0) at fluids.c:463
      #18 0x000000000044e1e2 in evaluate_embedded_scheme(scm_unused_struct*, Input const&, bool, Lily_parser*) (form=0x7fffe65a5570, start=..., safe=<optimized out>, parser=<optimized out>) at /home/work/lilypond/lily/include/lily-modules.hh:65
      #19 0x00000000006f8806 in Lily_lexer::eval_scm(scm_unused_struct*, Input, char) (this=this@entry=0x81a410, readerdata=readerdata@entry=0x7fffe65a5570, location=..., extra_token=extra_token@entry=35 '#') at lexer.ll:1108
      #20 0x000000000070561f in Lily_lexer::eval_scm_token(scm_unused_struct*, Input) (w=..., sval=0x7fffe65a5570, this=0x81a410) at /home/work/lilypond/lily/include/lily-lexer.hh:62
      #21 yyparse(Lily_parser*, scm_unused_struct**) (parser=<optimized out>, retval=<optimized out>) at parser.yy:452
      #22 0x0000000000712857 in Lily_parser::do_yyparse_trampoline(void*) (parser=parser@entry=0xa6e6c0) at parser.yy:4246
      #23 0x00007ffff7dcbf38 in scm_c_with_fluid (fluid=0x7fffe98d0380, value=0x7fffe7460480, cproc=cproc@entry=0x712840 <Lily_parser::do_yyparse_trampoline(void*)>, cdata=cdata@entry=0xa6e6c0) at fluids.c:463
      #24 0x00000000006fdeec in Lily_parser::do_yyparse() (this=this@entry=0xa6e6c0) at /home/work/lilypond/lily/include/lily-modules.hh:65
      #25 0x00000000006dcd28 in Lily_parser::parse_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=this@entry=0xa6e6c0, init="init.ly", name="/tmp/document.ly", out_name="document") at lily-parser.cc:118
      #26 0x00000000004fa129 in ly_parse_file(scm_unused_struct*) (name=<optimized out>) at lily-parser-scheme.cc:124
      #27 0x00007ffff7dc3cf3 in deval (x=<optimized out>, x@entry=0x7fffe80b8630, env=<optimized out>, env@entry=0x7fffe7460510) at eval.c:4232
      #28 0x00007ffff7dc16a6 in scm_dapply (proc=0x7fffe7460620, arg1=<optimized out>, args=0x7fffe7460510) at ../libguile/inline.h:305
      #29 0x00007ffff7e1c971 in scm_c_catch
          (tag=<optimized out>, body=body@entry=0x7ffff7e1c380 <scm_body_thunk>, body_data=body_data@entry=0x7fffffffcb50, handler=0x7ffff7e1c390 <scm_handle_by_proc>, handler_data=handler_data@entry=0x7fffffffcb48, pre_unwind_handler=0x0, pre_unwind_handler_data=0x7fffffffcb40)
          at throw.c:203
      #30 0x00007ffff7e1cba1 in scm_catch_with_pre_unwind_handler (key=<optimized out>, thunk=<optimized out>, handler=<optimized out>, pre_unwind_handler=<optimized out>) at throw.c:587
      #31 0x00007ffff7dc11a0 in scm_dapply (proc=0x7fffe99104f0, arg1=0x7fffea303940, args=0x7fffe7460560, args@entry=0x404) at eval.c:4930
      #32 0x00007ffff7dc3d41 in deval (x=<optimized out>, env=<optimized out>, env@entry=0x7fffe7460770) at eval.c:4378
      #33 0x00007ffff7dc3f73 in deval (x=0x7fffe80bba80, x@entry=0x7fffe80bbf00, env=0x7fffe7460770, env@entry=0x7fffe7461f30) at ../libguile/inline.h:305
      #34 0x00007ffff7dc16a6 in scm_dapply (proc=0x7fffe7461fc0, arg1=<optimized out>, args=0x7fffe7461f30) at ../libguile/inline.h:305
      #35 0x00007ffff7fc5709 in scm_srfi1_for_each (proc=0x7fffe7461fa0, arg1=0x7fffe7f06e30, args=0x404) at srfi-1.c:1516
      #36 0x00007ffff7dc3d5e in deval (x=<optimized out>, env=<optimized out>, env@entry=0x7fffe7f06780) at eval.c:4367
      #37 0x00007ffff7dc3f73 in deval (x=0x7fffe80baff0, env=0x7fffe7f06780, env@entry=0x7fffe7f06df0) at ../libguile/inline.h:305
      #38 0x00007ffff7dc386e in deval (x=0x7fffe7f069b0, x@entry=0x7fffe80c1a10, env=env@entry=0x7fffe7f06df0) at ../libguile/inline.h:305
      #39 0x00007ffff7dc16a6 in scm_dapply (proc=0x7fffe80c1670, arg1=<optimized out>, args=0x7fffe7f06df0) at ../libguile/inline.h:305
      #40 0x00000000005b7548 in Scm_variable::operator()(scm_unused_struct*) (arg1=<optimized out>, this=<optimized out>) at /home/work/lilypond/lily/include/lily-modules.hh:73
      #41 main_with_guile(void*, int, char**) () at main.cc:540
      #42 0x00007ffff7ddd083 in invoke_main_func (body_data=0x7fffffffd6b0) at init.c:367
      #43 0x00007ffff7db33fe in c_body (d=d@entry=0x7fffffffd650) at continuations.c:349
      #44 0x00007ffff7e1c971 in scm_c_catch
          (tag=tag@entry=0x104, body=body@entry=0x7ffff7db33f0 <c_body>, body_data=body_data@entry=0x7fffffffd650, handler=handler@entry=0x7ffff7db3410 <c_handler>, handler_data=handler_data@entry=0x7fffffffd650, pre_unwind_handler=pre_unwind_handler@entry=0x7ffff7e1d080 <scm_handle_by_message_noexit>, pre_unwind_handler_data=0x0) at throw.c:203
      #45 0x00007ffff7db3a18 in scm_i_with_continuation_barrier
          (body=body@entry=0x7ffff7db33f0 <c_body>, body_data=body_data@entry=0x7fffffffd650, handler=handler@entry=0x7ffff7db3410 <c_handler>, handler_data=handler_data@entry=0x7fffffffd650, pre_unwind_handler=0x7ffff7e1d080 <scm_handle_by_message_noexit>, pre_unwind_handler_data=pre_unwind_handler_data@entry=0x0) at continuations.c:325
      #46 0x00007ffff7db3b04 in scm_c_with_continuation_barrier (func=func@entry=0x7ffff7ddd060 <invoke_main_func>, data=data@entry=0x7fffffffd6b0) at continuations.c:367
      #47 0x00007ffff7e1a90a in scm_i_with_guile_and_parent (func=func@entry=0x7ffff7ddd060 <invoke_main_func>, data=data@entry=0x7fffffffd6b0, parent=<optimized out>) at threads.c:733
      #48 0x00007ffff7e1a960 in scm_with_guile (func=func@entry=0x7ffff7ddd060 <invoke_main_func>, data=data@entry=0x7fffffffd6b0) at threads.c:721
      #49 0x00007ffff7ddd1a9 in scm_boot_guile (argc=argc@entry=2, argv=argv@entry=0x7fffffffd848, main_func=main_func@entry=0x5b7340 <main_with_guile(void*, int, char**)>, closure=closure@entry=0x0) at init.c:350
      #50 0x000000000042490a in main(int, char**, char**) (argc=2, argv=0x7fffffffd848, envp=<optimized out>) at main.cc:877
      
       
      • Valentin Villenave

        IIUC, the Multi_measure_rest_engraver now relies on line-positions to place the grob, hence the crash?

         
        • David Kastrup

          David Kastrup - 2020-05-06

          That sounds like a sensible guess given the backtrace. It would appear that line-positions on a non-existent StaffSymbol is a bad idea...

           
  • Valentin Villenave

    Fix #5964: MM Rests shouldn’t segfault when there’s no StaffSymbol.

    https://codereview.appspot.com/576090043

     
  • Valentin Villenave

    Use `oneline’ when there’s either no staff OR a one-line staff

    https://codereview.appspot.com/576090043

     
  • Anonymous

    Anonymous - 2020-05-07

    Passes make, make check and a full make doc.

    Reg test diff attached

     
  • Anonymous

    Anonymous - 2020-05-09
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-05-09

    Patch on countdown for May 11th - although there are what look like relatively simple comments on Rietveld that need addressing

     
  • Valentin Villenave

    [proposal] Make Staff_symbol::line_count public and use it when <line_positions>’s not needed</line_positions>

    https://codereview.appspot.com/576090043

     
  • Anonymous

    Anonymous - 2020-05-09

    Passes make, make check and a full make doc.

    Reg test diff attached

     
  • Anonymous

    Anonymous - 2020-05-09
    • Needs: -->
    • Patch: new --> review
    • Type: -->