On Fri, Sep 12, 2014 at 8:53 AM, Scott Kostyshak <skost...@lyx.org> wrote: > If you have an updated TeX Live 2014 installation, exporting > examples/FeynmanDiagrams.lyx to PDF with LuaTeX will not work. But LyX > doesn't detect that something goes wrong. You need LuaTeX version > beta-0.79.1 to reproduce the following. The LuaTeX bug will not > trigger the LyX bug with LuaTeX version beta-0.76.0-2013061708, for > example. Also, I have no idea if this depends on the version of Qt. I > have confirmed that Kornel also sees the zero exit code but no > exported file, but we have similar systems. > > In the GUI, LyX says that the preview was successful and tries to open > the PDF. On the command line, LyX gives a zero exit code: > > If you run lualatex directly, you get a non-zero exit code: > > lualatex: ../../../tex-live-2014-04-01/texk/web2c/luatexdir/tex/mlist.w:2542: > make_ord: Assertion `varmem[(p)].hh.v.RH!=0' failed. > Aborted (core dumped) > $ echo $? > 134 > > This is LuaTeX, Version beta-0.79.1 (TeX Live 2014) (rev 4971) > restricted \write18 enabled. > (./FeynmanDiagrams.tex > LaTeX2e <2014/05/01> > Babel <3.9k> and hyphenation patterns for 79 languages loaded. > > If you run with LyX (I added some debug code for extra information): > > $ lyx -e pdf5 FeynmanDiagrams.lyx > lualatex: ../../../tex-live-2014-04-01/texk/web2c/luatexdir/tex/mlist.w:2542: > make_ord: Assertion `varmem[(p)].hh.v.RH!=0' failed. > support/Systemcall.cpp (294): Systemcall: 'lualatex > "FeynmanDiagrams.tex"' exit code is: 0 > d.errorMessage() is: The process crashed some time after starting > successfully. > d.exitStatusMessage() is: The process crashed. > $ echo $? > 0 > > The strange thing going on here is that SystemcallPrivate::exitCode is > returning 0 because QProcess::exitCode returns 0. I'm not sure why > this happens. The documentation states that QProcess::exitCode > "Returns the exit code of the last process that finished." Is the > point that because lualatex crashed the process didn't "finish"? I > don't think so, because when I use the following patch: > > @@ -610,7 +619,7 @@ int SystemcallPrivate::exitCode() > if (!process_) > return -1; > > - return process_->exitCode(); > + return process_->exitStatus(); > } > > SystemcallPrivate::exitCode correctly returns non-zero (it returns 1) > and it is also described as "Returns the exit status of the last > process that finished." After replacing exitCode with exitStatus and > applying the patch I just sent, LyX behaves as expected. But that is > not quite correct because I think we want to return the exit code and > not just the exit status. > > Any ideas?
In the documentation [1] for QProcess::exitCode() it states: "This value is not valid unless exitStatus() returns NormalExit." Attached is a patch. I use a magic number. What is the correct way to deal with this? I can think of three options: - a preprocessor macro defining -2 - throw and catch an error - have SystemcallPrivate::exitCode return a pair (the exit code and the exit status) Everything I read says preprocessor macros are mostly evil. I don't think throwing and catching errors is popular around here. But having exitCode() return a pair seems complicated for this simple task. What is the easy solution that I am missing? Scott [1] http://doc.qt.io/qt-5/qprocess.html#exitCode
From 5cf0de5e306de3f39d55df294482d83625cf2869 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> Date: Sat, 4 Apr 2015 02:01:46 -0400 Subject: [PATCH] Detect when an external command crashes This fixes a situation where LyX did not detect that something went wrong (that an external comman crashed) and reported that export was successful. To reproduce, use the following version of LuaTeX (the bug in LuaTeX causing the crash has since been fixed): LuaTeX, Version beta-0.79.1 (TeX Live 2014) (rev 4971) Then open FeynmanDiagrams.lyx and export with PDF (LuaTeX). In the documentation [1] for QProcess::exitCode() it states: "This value is not valid unless exitStatus() returns NormalExit." For more information, see: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg185317.html [1] http://doc.qt.io/qt-5/qprocess.html#exitCode --- src/support/Systemcall.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 9327613..023bc01 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -285,7 +285,10 @@ int Systemcall::startscript(Starttype how, string const & what, int const exit_code = d.exitCode(); if (exit_code) { - LYXERR0("Systemcall: '" << cmd << "' finished with exit code " << exit_code); + if (exit_code == -2) + LYXERR0("Systemcall: '" << cmd << "' crashed "); + else + LYXERR0("Systemcall: '" << cmd << "' finished with exit code " << exit_code); } return exit_code; @@ -610,7 +613,12 @@ int SystemcallPrivate::exitCode() if (!process_) return -1; - return process_->exitCode(); + // From Qt's documentation, in regards to QProcess::exitCode(), + // "This value is not valid unless exitStatus() returns NormalExit" + if (process_->exitStatus() == QProcess::NormalExit) + return process_->exitCode(); + else + return -2; } -- 2.1.0