QSA-interest Archive, November 2006
Re: Editor crashing with segfault
Message 1 in thread
It seems the original bug has been fixed in the current QSA 1.2.1,
however I ran into a very similar bug today:
Enter a equal sign alone in the new edit window, and then press the
enter key. Again the editor will crash with an assertion failing.
Any patch yet known for this?
JN> I have noticed the same thing. For me it is actually aborting on an
JN> assertion failure, not a segfault. This is the assert I get:
ASSERT: "i >>= 0" in file /usr/local/Trolltech/Qt-4.1.0/lib/
JN> QtCore.framework/Headers/qstring.h, line 692
JN> .. and here is the relevant portion of the stack at that point:
JN> #0 0x097d6860 in qFatal
JN> #1 0xbc122514 in QString::operator[] at quickinterpreter.cpp:692
JN> #2 0xbc0da458 in EditorCompletion::doArgumentHint at completion.cpp:585
JN> #3 0xbc0d86b8 in EditorCompletion::eventFilter at completion.cpp:377
JN> So it has something to do with the popup function completion. I
JN> hadn't bothered tracking it down further, instead I was just making
JN> sure to save my work often. :)
JN> But I figured as long as I've got it open in the debugger, I'd go
JN> ahead and fix it since you reminded me how much it was bugging me too
JN> -- so here's a patch:
JN> ==== tools/designer/editor/completion.cpp ====
JN> @@ -582,6 +582,7 @@
JN> QString part = cursor->paragraph()->string()->toString().mid
( j, cursor->>index() - j + 1 );
JN> function = function.simplifyWhiteSpace();
JN> for (;;) {
JN> + if (function.length() < 1) return false;
JN> if ( function[ (int)function.length() - 1 ] == '(' ) {
JN> function.remove( function.length() - 1, 1 );
JN> function = function.simplifyWhiteSpace();
JN> Enjoy! :)
JN> Joel Nordell
JN> Software Engineer
JN> ONEAC Corp.
JN> On Feb 16, 2006, at 12:11 PM, Seneca wrote:
>> I am using QSEditor standalone (without a QSProject), and found that
>> it is crashing very often at operations such as inserting or deleting
>> parantheses. Please try if this also happens to you with the following
>> minimal testprogram:
>>
>> #include <QApplication>
>> #include <qseditor.h>
>>
>> int main(int argc, char *argv[])
>> {
>> QApplication a(argc, argv);
>> QSEditor w(0);
>> w.show();
>> a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
>> return a.exec();
>> }
>>
>> When the window is shown, entering a single opening parantheses as
>> very first character will crash the application. If I however enter
>> something as:
>>
>> function x(
>>
>> It does not crash at the parantheses input. I therefore suspect a bug
>> in the syntax highlighter.
>>
>> I am on Windows XP, Qt 4.1.0, QSA 1.2.0
>>
>> --
>> Seneca
>>
>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-
>> request@xxxxxxxxxxxxx
JN> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
--
[ signature omitted ]
Message 2 in thread
Sorry for self replying, but I found a patch for the problem:
--- yyindent.orig 2006-02-28 14:21:18.000000000 +0100
+++ yyindent.cpp 2006-11-08 18:27:55.640625000 +0100
@@ -735,7 +735,7 @@
end of the unfinished lines or by unbalanced
parentheses.
*/
- if ( QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
+ if ( j > 0 && QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
(*yyLine)[j + 1] != '=' ) {
if ( braceDepth == 0 && delimDepth == 0 &&
j < (int) yyLine->length() - 1 &&
Thanks,
Seneca
You wrote at Mittwoch, 8. November 2006 17:32:
S> It seems the original bug has been fixed in the current QSA 1.2.1,
S> however I ran into a very similar bug today:
S> Enter a equal sign alone in the new edit window, and then press the
S> enter key. Again the editor will crash with an assertion failing.
S> Any patch yet known for this?
JN>> I have noticed the same thing. For me it is actually aborting on an
JN>> assertion failure, not a segfault. This is the assert I get:
ASSERT: "i >>>= 0" in file /usr/local/Trolltech/Qt-4.1.0/lib/
JN>> QtCore.framework/Headers/qstring.h, line 692
JN>> .. and here is the relevant portion of the stack at that point:
JN>> #0 0x097d6860 in qFatal
JN>> #1 0xbc122514 in QString::operator[] at quickinterpreter.cpp:692
JN>> #2 0xbc0da458 in EditorCompletion::doArgumentHint at completion.cpp:585
JN>> #3 0xbc0d86b8 in EditorCompletion::eventFilter at completion.cpp:377
JN>> So it has something to do with the popup function completion. I
JN>> hadn't bothered tracking it down further, instead I was just making
JN>> sure to save my work often. :)
JN>> But I figured as long as I've got it open in the debugger, I'd go
JN>> ahead and fix it since you reminded me how much it was bugging me too
JN>> -- so here's a patch:
JN>> ==== tools/designer/editor/completion.cpp ====
JN>> @@ -582,6 +582,7 @@
JN>> QString part = cursor->paragraph()->string()->toString().mid
( j, cursor->>>index() - j + 1 );
JN>> function = function.simplifyWhiteSpace();
JN>> for (;;) {
JN>> + if (function.length() < 1) return false;
JN>> if ( function[ (int)function.length() - 1 ] == '(' ) {
JN>> function.remove( function.length() - 1, 1 );
JN>> function = function.simplifyWhiteSpace();
JN>> Enjoy! :)
JN>> Joel Nordell
JN>> Software Engineer
JN>> ONEAC Corp.
JN>> On Feb 16, 2006, at 12:11 PM, Seneca wrote:
>>> I am using QSEditor standalone (without a QSProject), and found that
>>> it is crashing very often at operations such as inserting or deleting
>>> parantheses. Please try if this also happens to you with the following
>>> minimal testprogram:
>>>
>>> #include <QApplication>
>>> #include <qseditor.h>
>>>
>>> int main(int argc, char *argv[])
>>> {
>>> QApplication a(argc, argv);
>>> QSEditor w(0);
>>> w.show();
>>> a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
>>> return a.exec();
>>> }
>>>
>>> When the window is shown, entering a single opening parantheses as
>>> very first character will crash the application. If I however enter
>>> something as:
>>>
>>> function x(
>>>
>>> It does not crash at the parantheses input. I therefore suspect a bug
>>> in the syntax highlighter.
>>>
>>> I am on Windows XP, Qt 4.1.0, QSA 1.2.0
>>>
>>> --
>>> Seneca
>>>
>>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-
>>> request@xxxxxxxxxxxxx
JN>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
S> --
S> Seneca
S> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
--
[ signature omitted ]
Message 3 in thread
Ok, I'll shut up now (hopefully), but there was another case that was
not handled by my previous patch. So here's a patched patch :)
--- yyindent.orig 2006-02-28 14:21:18.000000000 +0100
+++ yyindent.cpp 2006-11-08 18:50:04.578125000 +0100
@@ -735,8 +735,8 @@
end of the unfinished lines or by unbalanced
parentheses.
*/
- if ( QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
- (*yyLine)[j + 1] != '=' ) {
+ if ( j > 0 && QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
+ (j == yyLine->length()-1 || (*yyLine)[j + 1] != '=' )) {
if ( braceDepth == 0 && delimDepth == 0 &&
j < (int) yyLine->length() - 1 &&
!yyLine->endsWith(QString::fromLatin1(",")) &&
Thanks,
Seneca
You wrote at Mittwoch, 8. November 2006 18:40:
S> Sorry for self replying, but I found a patch for the problem:
S> --- yyindent.orig 2006-02-28 14:21:18.000000000 +0100
S> +++ yyindent.cpp 2006-11-08 18:27:55.640625000 +0100
S> @@ -735,7 +735,7 @@
S> end of the unfinished lines or by unbalanced
S> parentheses.
S> */
S> - if ( QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
S> + if ( j > 0 && QString("!=<>").find((*yyLine)[j - 1]) == -1 &&
S> (*yyLine)[j + 1] != '=' ) {
S> if ( braceDepth == 0 && delimDepth == 0 &&
S> j < (int) yyLine->length() - 1 &&
S> Thanks,
S> Seneca
S> You wrote at Mittwoch, 8. November 2006 17:32:
S>> It seems the original bug has been fixed in the current QSA 1.2.1,
S>> however I ran into a very similar bug today:
S>> Enter a equal sign alone in the new edit window, and then press the
S>> enter key. Again the editor will crash with an assertion failing.
S>> Any patch yet known for this?
JN>>> I have noticed the same thing. For me it is actually aborting on an
JN>>> assertion failure, not a segfault. This is the assert I get:
ASSERT: "i >>>>= 0" in file /usr/local/Trolltech/Qt-4.1.0/lib/
JN>>> QtCore.framework/Headers/qstring.h, line 692
JN>>> .. and here is the relevant portion of the stack at that point:
JN>>> #0 0x097d6860 in qFatal
JN>>> #1 0xbc122514 in QString::operator[] at quickinterpreter.cpp:692
JN>>> #2 0xbc0da458 in EditorCompletion::doArgumentHint at completion.cpp:585
JN>>> #3 0xbc0d86b8 in EditorCompletion::eventFilter at completion.cpp:377
JN>>> So it has something to do with the popup function completion. I
JN>>> hadn't bothered tracking it down further, instead I was just making
JN>>> sure to save my work often. :)
JN>>> But I figured as long as I've got it open in the debugger, I'd go
JN>>> ahead and fix it since you reminded me how much it was bugging me too
JN>>> -- so here's a patch:
JN>>> ==== tools/designer/editor/completion.cpp ====
JN>>> @@ -582,6 +582,7 @@
JN>>> QString part = cursor->paragraph()->string()->toString().mid
( j, cursor->>>>index() - j + 1 );
JN>>> function = function.simplifyWhiteSpace();
JN>>> for (;;) {
JN>>> + if (function.length() < 1) return false;
JN>>> if ( function[ (int)function.length() - 1 ] == '(' ) {
JN>>> function.remove( function.length() - 1, 1 );
JN>>> function = function.simplifyWhiteSpace();
JN>>> Enjoy! :)
JN>>> Joel Nordell
JN>>> Software Engineer
JN>>> ONEAC Corp.
JN>>> On Feb 16, 2006, at 12:11 PM, Seneca wrote:
>>>> I am using QSEditor standalone (without a QSProject), and found that
>>>> it is crashing very often at operations such as inserting or deleting
>>>> parantheses. Please try if this also happens to you with the following
>>>> minimal testprogram:
>>>>
>>>> #include <QApplication>
>>>> #include <qseditor.h>
>>>>
>>>> int main(int argc, char *argv[])
>>>> {
>>>> QApplication a(argc, argv);
>>>> QSEditor w(0);
>>>> w.show();
>>>> a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
>>>> return a.exec();
>>>> }
>>>>
>>>> When the window is shown, entering a single opening parantheses as
>>>> very first character will crash the application. If I however enter
>>>> something as:
>>>>
>>>> function x(
>>>>
>>>> It does not crash at the parantheses input. I therefore suspect a bug
>>>> in the syntax highlighter.
>>>>
>>>> I am on Windows XP, Qt 4.1.0, QSA 1.2.0
>>>>
>>>> --
>>>> Seneca
>>>>
>>>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-
>>>> request@xxxxxxxxxxxxx
JN>>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
S>> --
S>> Seneca
S>> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
S> --
S> Seneca
S> To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
--
[ signature omitted ]
Message 4 in thread
Seneca wrote:
> Ok, I'll shut up now (hopefully), but there was another case that was
> not handled by my previous patch. So here's a patched patch :)
Hi Seneca,
Thanks for these patches. I'll see if I can't get them into the next
release.
best regards,
Gunnar
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx