Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Crash using QPainter from secondary thread

Crash using QPainter from secondary thread

Scheduled Pinned Locked Moved General and Desktop
17 Posts 8 Posters 14.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jim_kaiser
    wrote on last edited by
    #8

    Will try to repro..

    [Edit: Ubuntu 10.04 Qt SDK 1.1.1 Qt 4.7.4.. works.. no crash.. ]

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bourbon
      wrote on last edited by
      #9

      Ah, thanks. That's interesting.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #10

        Sorry, one mistake, I used 4.7.2.
        Mingw --> crash, msvs2008 --> works
        4.7.0 msvs2008 --> works

        very strange...

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bourbon
          wrote on last edited by
          #11

          Does this sound like something that should be reported on the Qt bugtracker? If so, where do I do that?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #12

            "For info on how to post a bug....":http://developer.qt.nokia.com/wiki/ReportingBugsInQt

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #13

              [quote author="bourbon" date="1308069402"]Does this sound like something that should be reported on the Qt bugtracker? If so, where do I do that?[/quote]

              It does to me. Sounds like a regression, and those are generally taken quite seriously. Don't forget to attach your example to reproduce the issue, link to this topic, and add a tag to this topic with the bug id (QTBUG-#####)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #14

                The first thing that comes in my mind is that you're not end()ing the painting before releasing the lock, thus you're relying on the QPainter dtor (which will end the painting itself).

                There's an obvious race condition there, and I'm confident that helgrind would have told you so. Try adding end() there, or switch to QMutexLocker.

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Franzk
                  wrote on last edited by
                  #15

                  The latter will probably give cleaner code.

                  "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bourbon
                    wrote on last edited by
                    #16

                    The crash occurs in the very first call to painter.drawLine(), so I don't think it's a race condition.
                    I didn't realise I shold be calling end(), I've added it but it makes no difference (the code never reaches it).

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlangezaal
                      wrote on last edited by
                      #17

                      I have posted the root cause, a small project to reproduce it and a temporary workaround in the Bugtracker for this bug: QTBUG-19886

                      It is caused by a stack mis-alignment of the newly created thread. It affects the drawing engine which expects 16-byte alignment for the used SSE2 instructions.
                      It appears to only occur on windows XP. And happens when a QPainter::drawImage is done on a different thread. The stack on the new thread (QThread subclass and started with start()) is NOT 16-bit aligned, and causes a Segmentation Fault on
                      the MMX instruction PANDN in qdrawhelper_sse2.cpp.

                      The only (dirty) workaround I can think of is to manually push extra bytes on the stack in case it is not aligned to realign the SP to a 16-byte boundary. And this seems to work quite well, no more crashes!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved