Page 2 of 2 FirstFirst 12
Results 21 to 39 of 39

Thread: 64-bit Qt for windows: QtScript crashes.

  1. #21
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    It's many megabytes of ECMAScript parser . Very hard to find out what causes access violation. Really lots of code O_O.

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    I don't want you to debug the parser, just your script.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #23
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Already done, this is a stripped down version of 30k+ script that was originally crashing. If i remove or change ANY line from this extremly simple script, crash WILL NOT reproduce O_O. Crash is reproduces randomly inside for(;; ) loop - if step-by-step script code crash will not reproduce.

    Qt Code:
    1. function OnStart()
    2. {
    3. var a = [ [ 0 ] ];
    4. for( var i = 0; i < 3; i ++ )
    5. {
    6. for( var j = 0; j < 100; j ++ )
    7. {
    8. "a" + a[ 0 ][ 0 ];
    9. }
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Of course a step by step crash won't reproduce if the problem is a race condition. Please insert some debugging statements in the script to see where it crashes. Also does it change anything if you just evaluate the contents of the function instead of calling the function?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #25
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Of course a step by step crash won't reproduce if the problem is a race condition
    Latest crash sample is a single threaded code. How race condition can occur in one thread?

    Please insert some debugging statements in the script to see where it crashes
    Not needed, it's clear by looking at crash code that it crashes at bytecode interpreter while executing bytecode equivalent of
    Qt Code:
    1. a[ 0 ][ 0 ]
    To copy to clipboard, switch view to plain text mode 

    Also does it change anything if you just evaluate the contents of the function instead of calling the function?
    No crash if function is not called.

  6. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Quote Originally Posted by eyeofhell View Post
    Not needed, it's clear by looking at crash code that it crashes at bytecode interpreter while executing bytecode equivalent of
    Qt Code:
    1. a[ 0 ][ 0 ]
    To copy to clipboard, switch view to plain text mode 
    Is the "a" array really two dimentional (check, don't assume)?

    No crash if function is not called.
    So this works?
    Qt Code:
    1. engine.evaluate(" var a = [ [ 0 ] ]; \
    2. for( var i = 0; i < 3; i ++ ) \
    3. { \
    4. for( var j = 0; j < 100; j ++ ) \
    5. { \
    6. \"a\" + a[ 0 ][ 0 ]; \
    7. } \
    8. }");
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #27
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Is the "a" array really two dimentional (check, don't assume)?
    In my script it is:

    Qt Code:
    1. var a = [ [ 0 ] ];
    To copy to clipboard, switch view to plain text mode 

    I don't have expert ECMAScript knowledge, but such definition looks surely to be two-dimensional.

    So this works? <evaluate skipped>
    Yep. And code after it crash:

    Qt Code:
    1. for(;;)
    2. {
    3. QScriptValue oFnStart = oEngine.evaluate( "OnStart" );
    4. Q_ASSERT( oFnStart.isFunction() );
    5. oFnStart.call(); // Crash here in deep bytecode interpreter internals.
    6. }
    To copy to clipboard, switch view to plain text mode 

  8. #28
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Quote Originally Posted by eyeofhell View Post
    In my script it is:

    Qt Code:
    1. var a = [ [ 0 ] ];
    To copy to clipboard, switch view to plain text mode 

    I don't have expert ECMAScript knowledge, but such definition looks surely to be two-dimensional.
    See my last post again.



    Yep. And code after it crash:

    Qt Code:
    1. for(;;)
    2. {
    3. QScriptValue oFnStart = oEngine.evaluate( "OnStart" );
    4. Q_ASSERT( oFnStart.isFunction() );
    5. oFnStart.call(); // Crash here in deep bytecode interpreter internals.
    6. }
    To copy to clipboard, switch view to plain text mode 
    See my last post again.

    Read it carefully this time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #29
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Is the "a" array really two dimentional (check, don't assume)?
    Yes, "a" array is 2-dimentional. Calling evaluate( "a.length" ) returns 1 and calling evaluate( "a[ 0 ].length" ) also returns 1 - it's 1x1 2-dimentional array.

    So this works?
    Qt Code:
    1. engine.evaluate(" var a = [ [ 0 ] ]; \
    2. for( var i = 0; i < 3; i ++ ) \
    3. { \
    4. for( var j = 0; j < 100; j ++ ) \
    5. { \
    6. \"a\" + a[ 0 ][ 0 ]; \
    7. } \
    8. }");
    To copy to clipboard, switch view to plain text mode 
    Yes, this works.

  10. #30
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    So the actual problem is with
    Qt Code:
    1. oFnStart.call();
    To copy to clipboard, switch view to plain text mode 
    and not the script itself. Please check if the example in Qt docs for QScriptValue::call() works for you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #31
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Original Qt call() example did not crash:

    Qt Code:
    1. QScriptEngine engine;
    2. engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }");
    3. engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }");
    4.  
    5. QScriptValue global = engine.globalObject();
    6. QScriptValue fullName = global.property("fullName");
    7. QScriptValue who = global.property("somePerson");
    8. qDebug() << fullName.call(who).toString(); // "John Doe"
    9.  
    10. engine.evaluate("function cube(x) { return x * x * x; }");
    11. QScriptValue cube = global.property("cube");
    12. QScriptValueList args;
    13. args << 3;
    14. qDebug() << cube.call(QScriptValue(), args).toNumber(); // 27
    To copy to clipboard, switch view to plain text mode 

    After adding my script and loop to Qt call() example it crashes:

    Qt Code:
    1. QScriptEngine engine;
    2. engine.evaluate( "function fullName(){var a=[[0]]; a[0][0];}" );
    3. QScriptValue global = engine.globalObject();
    4. QScriptValue fullName = global.property("fullName");
    5. for(;;)
    6. {
    7. fullName.call();
    8. }
    To copy to clipboard, switch view to plain text mode 

  12. #32
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    What if you add the loop to the example program? And what if you remove the loop from your program?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #33
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    If i add a loop to example program it will not crash - Qt script must be exactly what i have specified.
    If i remove loop from my program it will not crash.

    This is some kind of weird combination of exactly specific script and a loop O_O. The script is a reduced version of my original 30+ kb script, so i think it will crash on any script large and complex enough, with a loop . On 64-bit windows only.

  14. #34
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Quote Originally Posted by eyeofhell View Post
    i think it will crash on any script large and complex enough, with a loop . On 64-bit windows only.
    I don't think so. In my opinion the problem is with QScriptValue::call() and not the script itself. Add a loop around the code I have written in post #26 of this thread. If it doesn't crash then complexity of the script is irrelevant (I'd be surprised if it was relevant).

    Come to think of it, what exactly do you hope to obtain with your code? What is the point of using QScriptValue::call() in this situation? Why not simply do:
    Qt Code:
    1. oEngine.evaluate( "OnStart()" );
    To copy to clipboard, switch view to plain text mode 

    I'm sure you can add code to check if OnStart() is callable at all and even if not, you will get an exception from the script where you can easily determine what happened.

    By the way, what edition of Qt are you using? LGPL or commercial? They have different QtScript backends by default. The LGPL one has JIT compilation, maybe that is causing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #35
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    I don't think so. In my opinion the problem is with QScriptValue::call() and not the script itself.
    Yes, i mean script complex enough, 64-bit, loop and call inside a loop .

    Why not simply do: oEngine.evaluate( "OnStart()" );
    It will crash . Crash is inside QtScript code execution. I have carefully tested all ways to invoke a script function: evaluate( "foo" ).call(), globalObject().getProperty( "foo" ).call(), evaluate( "foo()" ) and connecting signals to slots inside of script. Anything will crash on QtScript execution if script is from my example, it's execution is inside a loop and windows is 64-bit .

    By the way, what edition of Qt are you using? LGPL or commercial? They have different QtScript backends by default. The LGPL one has JIT compilation, maybe that is causing the problem.
    I'm using LGPL version. Is it possible to disable JIT compilation in LGPL version?

  16. #36
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    Quote Originally Posted by eyeofhell View Post
    I'm using LGPL version. Is it possible to disable JIT compilation in LGPL version?
    You can rebuild QtScript with the other backend and see if it helps.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #37
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    You can rebuild QtScript with the other backend and see if it helps.
    Thanks. What i need to do in order to rebuild QtScript with different back-end? Some defines, nmake targets or what?

  18. #38
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 64-bit Qt for windows: QtScript crashes.

    To disable JIT, issue:

    configure -no-javascript-jit

    and rebuild Qt.

    I'm not sure how to change the backend, you have to search for it in the docs, I'm sure I have seen it somewhere (maybe it was somewhere in the Internet? At Qt Labs maybe?). Probably issuing -no-webkit would do the trick but that's a bit of a drastic method of doing this.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #39
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 64-bit Qt for windows: QtScript crashes.

    To disable JIT, issue:
    configure -no-javascript-jit
    and rebuild Qt.
    Windows version of 'configure' don't support '-no-javascript-jit'. The only 'configure' key on windows i can see that is related to QtScript subsystem are '-script' and '-noscript'.

Similar Threads

  1. Replies: 0
    Last Post: 25th November 2009, 07:46
  2. QTScript - getting the name of a QScriptValue
    By android_ in forum Qt Programming
    Replies: 7
    Last Post: 28th October 2009, 14:24
  3. Please help with QtScript
    By Haccel in forum Qt Programming
    Replies: 0
    Last Post: 16th December 2008, 05:59
  4. QtScript
    By QTInfinity in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 20:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.