-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qtbase crash on Windows #28
Comments
Similar behaviour experienced when using the master branch and building against Qt5.2.0 (still R 3.1.0, Win7 SP1 32bit). The
Another attempt gives a stack trace:
The
|
Probably related to the event loop issues. Too many threads. |
Do you think it can be solved (in near future)? Or would some workaround help temporarily? |
It's weird how the trace (in both the 4.8 and 5.2 cases) start with the seemingly unrelated Runzip(). First would be to confirm the multi-thread hypothesis. One way would be to modify the paintEvent callback in that characterWidget demo to just print a debug message and then enter an infinite loop. If there is one thread, it should print the message only once. It could be that there is actually something wrong with QPainter, or how we are using it. |
Trying the test you propose I can see the debug print from within the modified
|
Yea, I'm pretty sure this is just due to accidental multi-threading and race conditions. The intern at Amazon tried to fix this by basically being more aggressive about updating in sync with R, but I think even Qt does not fare well when there are multiple threads. One test would be to run something via Rscript, i.e., something without the R Windows GUI. I'm pretty sure it's the Windows GUI that somehow drives the Qt event loop in a different thread. |
Previously, I did not use R win GUI, but Rterm.exe. However, the problem persists even when running via Rscript. It seems that the Qt event loop gets driven in thread 5, while the painter is active in thread 1. Thread 1:
Thread 5:
|
That's actually on purpose. We run our own thread that is synchronized with the R event loop in thread 1. It should not cause any trouble. So many this bug is pointing at something deeper; it's just so hard to disentangle things when errors happen within Qt, and only on Windows. |
I'm ready to help with testing, limited debugging etc. |
Do you have the process for building it documented somewhere? I will just follow that and start debugging things. Thanks! |
Thanks! i) do not use g++ from RTools, but from MinGW, preferrably the one coming with/binary compatible with Qt. It seems that Qt 4.x (at least 4.8.2) asks for a specific version of MinGW. Qt 5.x (at least 5.2.1) comes with its own copy of MinGW (not sure if it gets installed by default). ii) if you run into linking problems of multiple definition of Note that the I can't guarantee this will work in general, but I think that's what worked for me on my Win7 VM. I can't get my hands on the VM just now to double check that, but I believe that the other issues have been fixed already. |
I've just rechecked the installation on Win7 32bit with: To be more specific, I have the following environment variables set:
|
Just curious about the status - any news, please? Thanks. |
Taking a look at the weird stacktrace below (obtained under the same conditions as above) I'm curious whether the problem could not be related to some g++ problems on the windows platform. Or do you think that the stacktrace could simply be a problem of gdb having hard times to restore the stack frames? Not a demonstration of real problems with the qtbase built there?
BTW I've tried adding "-ggdb" to "set_target_properties" and/or "set(CMAKE_CXX_FLAGS "-m32 -ggdb")" in |
I apologize for not being able to focus on this. Not sure what could be causing the issue. I'm pretty sure the "corrupt stack" is just an indirect symptom. Need to get at the root cause. Could be compiler issues, could be the event loop, who knows. |
I promise to look into this over the holidays. |
Thanks. Over the last couple of weeks, I've tried to investigate this issue a little bit deeper by compiling Qt5.2.0 from sources and enriching the sources with some debugs. However, I'm afraid I'm not any closer to a solution. Basically, the problem I face is caused by A representative log looks like this:
Note that in the second call to By printing the As I expected the issue could be caused by multithread-related, I tried to identify individual threads by the "called by" info shown above. It consists of The backtrace and thread info relevant to the problem above:
A digest of
Note that the Some technical comments I mention mostly for (my) reference:
I attempted to solve it by removing the
this resulted in:
I therefore tried to add
producing
Then I was able to link
|
Thanks for all of your efforts. I think this might just be memory corruption, if it is true that nothing is setting the state to |
I've managed to get qtbase to build and load, but running the characterWidget demo is blocking the R console, and none of the characters are drawn (it appears that there is some error invoking the paintEvent override). Have you experienced this? |
I usually use Rscript from within gdb and experience a crash while drawing the characters or the grid (i.e. the rectangles around the characters). When running from within the R console directly (wout gdb), I experience later crashes: when drawing characters, or even after all the characters have been drawn, on subsequent drawings (e.g. after asking for bold face characters). |
I've just run across Dr. Memory - a multiplatform memory debugger: http://drmemory.org. It seems to work well under 32bit Windows 7. Running the characterWidget demo under Rscript, Dr.Memory reported e.g.:
Would that help? |
Thanks, I had installed drmemory and was planning on doing the same thing. Do you think you could build Qt with debugging symbols, so that the stacktrace is more informative? |
I have built both the release and debug Qt versions (e.g. *.dll and *d.dll) . How do I make qtbase to use the debug version, please? |
Never done it before, but I think you can pass -DCMAKE_BUILD_TYPE=DEBUG to the cmake command from the Makefile. |
Thanks. Adding -DCMAKE_BUILD_TYPE=DEBUG to CMAKE_ARGS in src/Makefile.common and src/Makefile.win resulted in the following error when loading qtbase:
which perhaps (based on google search) signals a mixture of release and debug libraries being used at the same time. Using ntldd (see https://github.com/LRN/ntldd) I could really spot such a mixture:
Can't tell where do the release versions come from. There are both debug and release versions of e.g. Qt5SQL and Qt5Widget in C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin. Note that qtbase.dll seems to be linked against both the debug and release versions of Qt5Widgets.dll for some reason. |
The dependency walker tool may offer some clues. |
The dependency walker helped by specifying which symbols of one of the problematic libs (Qt5Widgets.dll) gets exposed, e.g._Z13qDrawWinPanelP8QPainterRK5QRectRK8QPalettebPK6QBrush. This symbol appears in libsmokeqt.a - even though I put "set(CMAKE_BUILD_TYPE Debug)" to kdebindings/smoke/qt/CMakeLists.txt (and others CMakeLists.txt in kdebindings). When building kdebindings, it seems that debug mode is turned on:
Still don't know why qtbase.dll links to release-version Qt libs. Do you think it is worthy to proceed further (to make use of debug Qt libs)? Would a file/line-enriched stacktrace really that helpful? |
If you set |
Thanks for the hint. The problem was qtbase.dll linking, in which release versions of Qt5 libs appeared:
I solved it manually by hacking the linking command, using debug versions of the .a libs:
Then, running the characterWidget.R in Rterm under Dr.Memory, I could see the debug info for Qt5Gui. The relevant problem reported was:
Decorating with some code gives:
I put the full Dr.Memory log I also tried enabling QT_DEBUG_DRAW. Then, the Next, I ran the demo with QT_DEBUG_DRAW enabled under Dr.Memory.
(perhaps not harmful?). However, errors 241+ seem to show huge memory corruption, e.g.:
The full log can be found at https://github.com/tsieger/qtbase/blob/logs/logs/150126/log_QT_DEBUG_DRAW_drmem.txt. |
Wow, thanks for all of that. It does look like there is corruption of the |
When turned
Full log: https://github.com/tsieger/qtbase/blob/logs/logs/150126/log_smoke_drmem.txt |
I'm not sure I spot anything wrong with |
You are right - there is no clear link between the BTW the fix for the memory violations during logging worked. Thanks. I also tried to disable some deallocations in I noticed that the problem arises (not sure if always) when processing an event recursively:
(Full log at https://github.com/tsieger/qtbase/blob/logs/logs/150126/log_smoke_drmem-reentrancy.txt) Maybe, some code involved is not reentrant? BTW it seems that some other people had problems similar to ours: https://bugreports.qt.io/browse/QTBUG-22102, Also, I tried to make the |
Thanks for this, again. It's interesting that my change fixed the logging issue. It seems very easy to make mistakes with some of these "smart" pointers; who knows where else things are going wrong. Now I am concerned about all of the stack imbalance errors in that log. Did you change something in the code for debugging? If not, then we will need to figure those out. |
I also notied that Qt 5.3.0 introduced a Direct2D-based paint engine for Windows. The current crash (and the one cited in 4-year-old, unfixed issue 22102) is in the raster paint engine... so it might be a workaround. |
Regarding the stack inbalances - that's the result of my "deallocation-disabling" hack to I tested qtbase with Qt 5.4.0 some time ago and it did not work. However, I don't know if the Direct2D engine got used, or even if it is available on my Win7 running in a vmware player. (I don't have much Windows graphics experience.) Do you think it could be made working easily? |
I think we should at least be using the latest stable version of Qt for this testing. Do you think you could upgrade? As far as enabling the Direct2D backend, there is no documentation, but I think you can set |
Having |
You would see it in the stack trace. Let's remember that Windows has never been very stable, thanks to the competing event loop problems. |
I can't see any Direct2D engine in the stacktrace. The problem then seems to be the very same as for Qt4.2.0 (touching NULL state() on recursive repaint):
|
Well, we can't know whether it uses the raster engine or not, because there are no debugging symbols in Qt. That might be a lot of effort to rebuild Qt though. |
I have hit this in Qt5.15.2. It happens when a widget repainting causes another paint event. In our case, during a paint event a widget was querying a color value using a scripting command, the scripting engine ran an event loop and scripting command were being echoed in a widget, resulting in a recursive painting. At the very least, there should be an easy way i the paint engine (QRasterPaintEngine for example) to detect recursive begin/end. |
R crashes running some qtbase demos.
E.g. running the
characterWidget
demo results in:The
sliders
demo results in:(Can't get stack trace in this case.)
Some other demos (
groupBox
,addressBook
,widget
) seem to work correctly.Testing on:
Windows 7 SP1 32bit
R 3.1.0
Qt 4.8.6
qtbase branch qt4
The text was updated successfully, but these errors were encountered: