Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-22926

Windows: Crash when creating a QScriptEngine in a native thread

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.7.4, 4.8.0, 5.2.0
    • Fix Version/s: 4.8.1, 5.3.2
    • Component/s: Qt Script
    • Environment:
      Windows 7, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010/2012
    • Commits:
      4e73732d3e72ea59d39ec5a5c01c2e76bbff7dc1 (4.8) , 71f6dee8791c95fd862ca3651d7f4b7d6b9f440e (5.3)

      Description

      When a QScriptEngine is created in a native thread on Windows a crash occurs. It appears to be a race condition when destroying data for the adopted thread. This only happens for me on Windows. I have not been able to reproduce this on Linux or Mac OS X. The workaround is to create the QScriptEngine in a QThread instead of the native Windows thread.

      I am attaching 2 examples:

      main_crash.cpp - shows how the crash happens
      main_nocrash.cpp - shows the workaround I am using to prevent this crash

      Let me also note that this only happens when I create a QScriptEngine whether on the heap or the stack. If I create a regular QObject, this issue does not occur. It happens in Qt 4.7.4 and Qt 4.8.0 RC for me.

        Attachments

        1. backtrace_gdb.txt
          5 kB
        2. backtrace_msvc2008.txt
          3 kB
        3. main_crash.cpp
          0.7 kB
        4. main_nocrash.cpp
          0.9 kB
        5. purify.txt
          11 kB
        6. qscriptenginetest_v1.zip
          2 kB
        7. qscriptenginetest_v2_logs.zip
          20 kB
        8. qscriptenginetest_v2.zip
          1 kB
        9. qtbug22296.zip
          1 kB
        10. QtScriptCrash-5.2.0.patch
          0.5 kB
        11. qtscriptthreadcrash_v1_vs2012_crashstack.txt
          97 kB
        12. qtscriptthreadcrash_v1_vs2012.zip
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            andysh Andy Shaw
            Reporter:
            shapochniky Yan Shapochnik
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes