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.



Don Armstrong

-- 
I shall require that [a scientific system's] logical form shall be
such that it can be singled out, by means of empirical tests, in a
negative sense: it must be possible for an empirical scientific system
to be refuted by experience.
 -- Sir Karl Popper _Logic of Scientific Discovery_ ยง6

http://www.donarmstrong.com              http://rzlab.ucr.edu
From d8f457a8016d7f815d545aa675c4f050cefa5335 Mon Sep 17 00:00:00 2001
From: Don Armstrong <d...@donarmstrong.com>
Date: Fri, 28 Dec 2012 11:53:05 -0800
Subject: [PATCH] do not allow s to be garbage collected in
 Font_metric::mark_smob before the function is done with it.

---
 lily/font-metric.cc |    3 +++
 1 file changed, 3 insertions(+)

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_;
 }
 
-- 
1.7.10.4

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

Reply via email to