On 11/19/2014 04:43 PM, Georg Baum wrote:
Hi,

while investigating http://www.lyx.org/trac/ticket/9336 I found out a
fundamental problem with our multithreaded export: The GNU libstdc++ gives
only a relatively weak thread-safety guarantee about std::basic string. It
is not completely thread-safe in the POSIX sense. The reason for this lies
in the employed copy-on-write technique, which is not used in other STL
implementations such as the one in clang or MSVC. It is even explicitly
forbidden in the new C++11 standard, and the gcc folks already acknowledged
that they will get rid of it, but since this is an ABI incompatible change
they want to wait until they have several such changes to do all in one go.
For details please see the excellent gcc bug report by James Kanze (who is a
C++ expert) at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334,
especially https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334#c21, which
describes almost exactly the situation we have with the document language.

This looks all rather theoretical, but in practice it means that it is quite
easy to produce crashes if you use LyX built with #define EXPORT_in_THREAD 1
and gcc, and start an export, depending on the document (master-child setups
seem to be much more vulnerable). The thing which seems to be most affected
is Language::babel_, which is copied a lot, but problems could arise from
all std::string and docstring variables.

I'm not well informed enough about implementation details to have an opinion about whether this diagnosis is correct. But I am somewhat puzzled that we are only seeing this issue now. Of course, there may have been other random crashes that people haven't reported. But I have used LyX with threaded export enabled, on Linux, for a very long time, with large documents with lots of children, and I've never seen anything like this crash. I thus remain curious about the details of the document
itself. Is there something special about it that is triggering this?

Obviously, we need some substantial discussion before making any decision about what to do. I'm
going to cc a bunch of people to try to get their attention.

Richard

Reply via email to