http://www.lyx.org/trac/ticket/6503

This crash is caused by an infinite loop in Encodings::initMath, which 
recursively calls itself if a document includes itself (we already issue a 
warning about that, but in the given case, LyX crashes before the warning 
can be issued).

The fix is obviously to test whether child and parent are identical. I see 
two ways of doing this: either directly in the function (patch a) or 
upstream in Buffer::isChildren (patch b).

Which, if any, do you prefer?

Jürgen 
Index: src/Encoding.cpp
===================================================================
--- src/Encoding.cpp	(Revision 33282)
+++ src/Encoding.cpp	(Arbeitskopie)
@@ -557,7 +557,8 @@
 	BufferList::iterator bit = theBufferList().begin();
 	BufferList::iterator const bend = theBufferList().end();
 	for (; bit != bend; ++bit)
-		if (buffer.isChild(*bit))
+		// avoid recursive includes
+		if (buffer.isChild(*bit) && *bit != &buffer)
 			initUnicodeMath(**bit, false);
 #endif
 }

Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(Revision 33282)
+++ src/Buffer.cpp	(Arbeitskopie)
@@ -1804,6 +1804,9 @@
 
 bool Buffer::isChild(Buffer * child) const
 {
+	// avoid recursive includes
+	if (child == this)
+		return false;
 	return d->children_positions.find(child) != d->children_positions.end();
 }
 

Reply via email to