[cfe-dev] Locating the root cause of the error detected by UBSan
Roman Lebedev via cfe-dev
cfe-dev at lists.llvm.org
Mon Apr 8 01:30:50 PDT 2019
1. Make sure you built with debug symbols (-g)
2. Install debug symbols for all the libs you link to (well, at least
the ones in backtrace)
3. Read https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#stack-traces-and-report-symbolization
In particular, "Make sure llvm-symbolizer binary is in PATH."
I doubt it will accept llvm-symbolizer-${VERSION}, so you may need
to make a symlink
On Mon, Apr 8, 2019 at 11:27 AM Zhoulai Fu at Gmail <zhoulai.fu at gmail.com> wrote:
>
> Thank you! The "print_stracktrace" trick does help. I get something that is shown below, which traces the error back to the binary code of the buggy application (which is in C++). A naive question: With Clang, is it possible to get the offending line of the source code, like when you print a stracktrace of an exception in Java?
>
>
> /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:517:55: runtime error: -nan is outside the range of representable values of type 'int'
> #0 0x4b0ffb (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x4b0ffb)
> #1 0x4ab7b3 (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x4ab7b3)
> #2 0x4a501f (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x4a501f)
> #3 0x50a6af (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x50a6af)
> #4 0x509d3a (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x509d3a)
> #5 0x543be3 (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x543be3)
> #6 0x7fd2719a5d29 (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b4d29)
> #7 0x7fd2719b25c7 (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2c15c7)
> #8 0x7fd2719a6bb2 (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b5bb2)
> #9 0x7fd275c9505b (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x15b05b)
> #10 0x7fd275c9a515 (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x160515)
> #11 0x7fd27197738a (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x28638a)
> #12 0x7fd2719cc5ec (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2db5ec)
> #13 0x7fd2719ccaf0 (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2dbaf0)
> #14 0x7fd270160196 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4a196)
> #15 0x7fd2701603ef (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4a3ef)
> #16 0x7fd27016049b (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4a49b)
> #17 0x7fd2719cd7ea (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2dc7ea)
> #18 0x7fd271974b49 (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x283b49)
> #19 0x7fd27197cbeb (/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x28bbeb)
> #20 0x49f1eb (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x49f1eb)
> #21 0x49e9f1 (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x49e9f1)
> #22 0x7fd27069a82f (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
> #23 0x477588 (/home/zhfu/catkin_ws/devel/lib/turtlesim/turtlesim_node+0x477588)
>
>
> Zhoulai
>
> On Mon, Apr 8, 2019 at 9:38 AM Roman Lebedev <lebedev.ri at gmail.com> wrote:
>>
>> export UBSAN_OPTIONS="print_stacktrace=1"
>> might help
>>
>> On Mon, Apr 8, 2019 at 10:30 AM Zhoulai Fu at Gmail via cfe-dev
>> <cfe-dev at lists.llvm.org> wrote:
>> >
>> > Hi,
>> >
>> > I am running a robotic application on Ubuntu16. The application is compiled with Clang's UndefinedBehavior sanitizer with an "-g" option. I got a brief error message which seemed to indicate a bug somewhere:
>> >
>> > /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:517:55:
>> > runtime error: -nan is outside the range of representable values of type 'int'
>> >
>> > My guess is that the bug is from my application, not from the more mature QT. How could I determine which line in the source (which I can access) of the application that triggers this runtime error?
>> >
>> > Thanks.
>> >
>> > Zhoulai
>> >
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at lists.llvm.org
>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list