[SOLVED]Trying to get Address Sanitizer to work in Qt 5.3 on Ubuntu 14.04
I'm trying to diagnose seg faults on Ubuntu Linux 14.04 and have been fumbling around with "address sanitizer":http://code.google.com/p/address-sanitizer/ trying to get it to work. I have had no luck.
I have a manual compiler definition that I cloned from the Auto-detected GCC (x86 64bit) compiler with -fsanitize=address -fno-omit-frame-pointer for my 'Platform codegen flags:' and -fsanitize=address for my 'Platform linker flags:". This is the compiler that my selected kit is using. I am running in debug mode.
I have also added CONFIG+=address_sanitizer to qmake's "Additional arguments" field in the Build steps for the Qt 5.3.0Gcc 64-bit kit.
I've read "this post":http://blog.qt.digia.com/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/ but don't know what to do with the referenced "code review":https://codereview.qt-project.org/#change,43420. This comment is worrisome:
"Update: Apparently a stock gcc 4.8.0 has still issues with address-sanitizer: libasan isn’t linked automatically, an internal compiler error in qtbase … I’m personally using a gcc from 4.8 branch."
I get no output even when I trigger my segmentation fault.
Am I enabling it incorrectly?
Do I have to build my own Qt/Qt Creator to use this?
It looks like this should work with GCC (what I'm trying to do), but would it be easier to use clang?
Should I quit my job and go find a new one "driving an excavator":http://www.deere.com/common/media/images/product/excavators/290g_lc/JD_r4d014102_Excavator.png?
Thanks for reading,
Hi and welcome to devnet,
If you want to test the patch, just use the copy to clipboard button to the right of the download line and paste in a terminal in your own clone of qtbase then rebuild.
Hope it helps
[quote author="SGaist" date="1404249124"]Hi and welcome to devnet,[/quote] Thank you.
[quote author="SGaist" date="1404249124"]...test the patch, ...paste in a terminal in your own clone of qtbase then rebuild.[/quote]
The clone I mentioned earlier was just a result of me hitting the 'clone' button in the Build and Run Options dialog. I assume that is not the Clone you're talking about. So, please pardon my ignorance, but to make sure I understand what you are saying, I'll re-phrase it:
I DO need to "build my own Qt 5 from Git":https://qt-project.org/wiki/Building-Qt-5-from-Git. And the steps would be:
Get the source from Git
Run the patch script that I've copied from that page in a terminal window in the newly Git-ed qtbase directory.
"Build Qt 5":http://qt-project.org/doc/qt-5/build-sources.html with that patch applied.
Point Qt Creator to this local build of Qt 5 somehow?
Run application in debug mode and enjoy sanitizer spew with all our memory management mistakes.
Am I still confused?
Yes, indeed you do.
- If you are going to play with the sources several time, you should rather follow the Build Qt from Git guide.
- Preferences -> Build And Run -> Qt Version and then add a Kit using that version
- If everything went fine to that point…
Nop, seems you're not :)
Thank you... this worked. Unfortunately, the output wasn't that helpful... the excavator is sounding better and better.
==625== ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000a8 (pc 0x7f3afa3828da sp 0x7ffff18867a0 bp 0x7ffff18867c0 T0)
AddressSanitizer can not provide additional info.
#0 0x7f3afa3828d9 (/home/paul/qt5/qtbase/lib/libQt5Gui.so.5.3.1+0x35c8d9)
#1 0x45b805 (/home/paul/asc3_QtQuick2_CLEAN/build-qt-qt5_local_build_x86_64_bit_5_3_1-Debug/cobalt/cobalt+0x45b805)
#2 0x478c4f (/home/paul/asc3_QtQuick2_CLEAN/build-qt-qt5_local_build_x86_64_bit_5_3_1-Debug/cobalt/cobalt+0x478c4f)
#3 0x7f3af9b6d0d4 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x35a0d4)
#4 0x7f3af9b6e119 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x35b119)
#5 0x7f3afbf185ca (/home/paul/qt5/qtbase/lib/libQt5Quick.so.5.3.1+0x1e75ca)
#6 0x7f3afad253a9 (/home/paul/qt5/qtbase/lib/libQt5Widgets.so.5.3.1+0x1663a9)
#7 0x7f3afad229f1 (/home/paul/qt5/qtbase/lib/libQt5Widgets.so.5.3.1+0x1639f1)
#8 0x7f3af9b32c4f (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x31fc4f)
#9 0x7f3af9b367dc (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x3237dc)
#10 0x7f3af9b33f1a (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x320f1a)
#11 0x7f3af9b338bf (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x3208bf)
#12 0x7f3af9ba8a59 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x395a59)
#13 0x7f3af787ee03 (/lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0+0x48e03)
#14 0x7f3af787f047 (/lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0+0x49047)
#15 0x7f3af787f0eb (/lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0+0x490eb)
#16 0x7f3af9ba91fa (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x3961fa)
#17 0x7f3ae95c11cb (/home/paul/qt5/qtbase/plugins/platforms/libqxcb.so+0x971cb)
#18 0x7f3af9b2f987 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x31c987)
#19 0x7f3af9b2fc48 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x31cc48)
#20 0x7f3af9b33307 (/home/paul/qt5/qtbase/lib/libQt5Core.so.5.3.1+0x320307)
#21 0x7f3afa11a71f (/home/paul/qt5/qtbase/lib/libQt5Gui.so.5.3.1+0xf471f)
#22 0x7f3afad22212 (/home/paul/qt5/qtbase/lib/libQt5Widgets.so.5.3.1+0x163212)
#23 0x41b3a6 (/home/paul/asc3_QtQuick2_CLEAN/build-qt-qt5_local_build_x86_64_bit_5_3_1-Debug/cobalt/cobalt+0x41b3a6)
#24 0x7f3af8c4eec4 (/lib/x86_64-linux-gnu/libc-2.19.so+0x21ec4)
#25 0x419c38 (/home/paul/asc3_QtQuick2_CLEAN/build-qt-qt5_local_build_x86_64_bit_5_3_1-Debug/cobalt/cobalt+0x419c38)
Did you try Valgrind ?
I did, and I am getting some helpful output. Previously, I wasn't having any luck with it, but I have screwed with my implementation since then. Thanks again for the help!