Don Armstrong <d...@debian.org> writes:

> The attached patch fixes a segfault in mark_smob where s gets
> optimized away and garbage collected before m goes out of scope,
> leading to a segfault.
>
> There may be other cases of this bug floating around, but I didn't
> look particularly hard for them.

> diff --git a/lily/font-metric.cc b/lily/font-metric.cc
> index 6990afe..8ca88ef 100644
> --- a/lily/font-metric.cc
> +++ b/lily/font-metric.cc
> @@ -106,6 +106,9 @@ Font_metric::mark_smob (SCM s)
>  {
>    Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
>    m->derived_mark ();
> +  // we must do this to avoid s being optimized out and garbage
> +  // collected; leading to a segfault above.
> +  scm_remember_upto_here_1(s);
>    return m->description_;
>  }

That makes precious little sense: mark_smob is only called while garbage
collection is in progress, so garbage collection can't be triggered in
its middle.

-- 
David Kastrup


_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to