Le 17/11/2015 17:07, Richard Heck a écrit :
On 11/16/2015 05:53 PM, Guillaume Munch wrote:
Le 16/11/2015 20:22, Georg Baum a écrit :
Richard Heck wrote:


Recipe:

1. Open the User Guide.
2. Click somewhere in the main text.
3. Insert > Citation
4. Enter the search field and type "cap"
5. Hit search button.

Error: Software exception Detected
----------------------------------------
LyX has caught an exception, it will now attempt to save all unsaved
documents and exit.

Exception: regex_error

This is on Fedora 22, gcc 5.1.1, with configuration as:
--enable-build-type=dev.

The offending code is this assignment

           static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");

in escape_special_characters in GuiCitation.cpp. I would guess that
this
is a consequence of changes to the regex engine.

I can reproduce with gcc 5.1 in C++11-mode. This is most likely the same
problem as http://www.lyx.org/trac/ticket/9799, since the test fails
as well
for the same compiler, so I guess it happens with gcc4 in C++11 mode as
well. Nice to see that the unit test worked! Now we only need to
learn not
to ignore failing unit tests.

Some regex expert needs to find out whether the regex syntax we are
using is
only valid for boost::regex or for C++11 std::regex as well, and
depending
on the outcome we either need to change our regex, or file a gcc bug. Or
maybe it is some multithreading issue? The 'static' rings some alarm
bells...



If I may try to explain with my own words (because I really didn't get
your reasoning at first, being far from being a C++ regex expert).
Std::regex and boost::regex do not set the same regex style by default
(perl vs ECMAScript) but both support other styles by passing the
appropriate flag. The commit 4620034e already had fixed a crash a
while ago due the use of (what is now) std::regex in MSVC, by passing
automatically the flag to set the "grep" regex style instead of
ECMAScript.

But, in 394e1bf9 you did without passing this flag. The reason, if I
reconstruct correctly, is that std's ECMAScript style is only supposed
to be boost's perl style minus a few perl-isms; we shouldn't have to
set a style "grep" (that may even change the meaning of regexes!). The
most sensible cross-platform solution is to conform to the ECMAScript
subset, and if I infer correctly this is what you mean.

Once this is understood, we go to the ECMAScript standard and realize
that "[]" is interpreted as the empty class in ECMAScript. "[]…]" is a
perl-ism, and ] should be escaped.

Lesson for everybody apart from Georg: please write regexes according
to the ECMAScript standard in the future, even if boost is happy with
your perl-isms.

Here's a patch that locates a similar issue elsewhere. I did my fair
share of the exercise, can I please let other people test it and
commit the appropriate solution?

I can confirm that this fixes the original crash. I didn't check the
ExternalTransforms part of it, as I'm not sure how to do that, but one
would suppose it was right, too.


I am happy to commit that if that's what you want.

Reply via email to