rochus-keller / EbnfStudio

EbnfStudio can be used to edit and analyze EBNF grammars.
GNU General Public License v2.0
65 stars 10 forks source link

Segfault opening LsTools/syntax/LjAsm.ebnf #1

Closed mingodad closed 4 years ago

mingodad commented 4 years ago

Hello ! Thanks for the nice collection of tools that you've created ! After compiling EbnfStudio and looking to an example to test it, I tried to open the Oberon sintax and it worked fine but when trying to open LsTools/syntax/LjAsm.ebnf it segfaults.

Cheers !

rochus-keller commented 4 years ago

Welcome. On that OS/CPU are you using it? I work on a 32 bit Linux on x86 and it doesn't crash. I tried by Open command and by command line argument and cannot reproduce.

mingodad commented 4 years ago

Hello ! Sorry by not include that info in the first place ! I'm trying it on a lubuntu 18.04 64bits x86_64 i7 cpu. Cheers !

mingodad commented 4 years ago

Hello again ! I've compiled it without optimization and it doesn't segfault. Then I compiled with optimization and debug info and here is the stack trace:

Thread 1 "EbnfStudio" received signal SIGSEGV, Segmentation fault.
LaLexer::Tok::Tok (v=..., t=18 '\022', this=0x7fffffffd2d0) at LaParser.h:34
34          Tok(quint8 t = Invalid, const QByteArray& v = QByteArray() ):d_type(t),d_val(v){}
(gdb) bt
#0  0x00005555555b5e18 in LaLexer::Tok::Tok(unsigned char, QByteArray const&)
    (v=..., t=18 '\022', this=0x7fffffffd2d0) at LaParser.h:34
#1  0x00005555555b5e18 in LaLexer::token(unsigned char, int, QByteArray const&)
    (this=0x7fffffffd2d0, type=18 '\022', len=0, v=...) at LaParser.cpp:325
#2  0x00005555555b61ec in LaLexer::nextTokenImp() (this=0x7fffffffd2d0) at LaParser.cpp:245
#3  0x00005555555b6c8f in LaLexer::nextToken() (this=0x7fffffffd2d0) at LaParser.cpp:231
#4  0x00005555555b782b in LaParser::laFactor() (this=0x7fffffffd2d0) at LaParser.cpp:187
#5  0x00005555555b7ae2 in LaParser::laTerm() (this=0x7fffffffd2d0) at LaParser.cpp:133
#6  0x00005555555b7e72 in LaParser::laExpr() (this=0x7fffffffd2d0) at LaParser.cpp:89
#7  0x00005555555b8244 in LaParser::parse(QByteArray const&) (this=this@entry=0x7fffffffd2d0, str=...)
    at LaParser.cpp:53
#8  0x00005555555861c1 in EbnfSyntax::checkPredicates(EbnfSyntax::Node*) (this=0x555555e4fb80, node=0x55555606cbf0)
    at EbnfSyntax.cpp:775
#9  0x0000555555586023 in EbnfSyntax::checkPredicates(EbnfSyntax::Node*) (this=0x555555e4fb80, node=0x55555606cba0)
    at EbnfSyntax.cpp:789
#10 0x0000555555586023 in EbnfSyntax::checkPredicates(EbnfSyntax::Node*) (this=0x555555e4fb80, node=0x55555606cab0)
    at EbnfSyntax.cpp:789
#11 0x00005555555865ba in EbnfSyntax::checkPredicates() (this=0x555555e4fb80) at EbnfSyntax.cpp:731
#12 0x000055555558750d in EbnfSyntax::finishSyntax() (this=0x555555e4fb80) at EbnfSyntax.cpp:263
#13 0x000055555557a0c2 in EbnfEditor::parseText(QByteArray) (this=0x5555558f4800, ba=...) at EbnfEditor.cpp:229
#14 0x000055555557a33c in EbnfEditor::onUpdateModel() (this=0x5555558f4800)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:518
#15 0x00007ffff6724645 in QMetaObject::activate(QObject*, int, int, void**) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ffff67310b7 in QTimer::timeout(QTimer::QPrivateSignal) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007ffff6731418 in QTimer::timerEvent(QTimerEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007ffff672516b in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff747383c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

Cheers !

rochus-keller commented 4 years ago

Oops, seems that not everything is 64 bit clean yet. It's not immediately obvious what in LaParser could be a problem. Unfortunately I currently don't have time to debug it and on 32 bit where I'm working doesn't occur the issue. I will put a note in the readme that 64 bit doesn't fully work yet (i.e. only without optimization).

rochus-keller commented 4 years ago

I added a note to the readme and close the issue for now. Did you by chance try different optimization levels? Does it crash as soon as any optimization is on, or just with strong levels?