Skip to content
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

Add validation backtrace libbacktrace #394

Merged

Conversation

kswiecicki
Copy link
Contributor

@kswiecicki kswiecicki commented Mar 30, 2023

Libbacktrace backtrace can be enabled using cmake option VAL_USE_LIBBACKTRACE_BACKTRACE, it is set to OFF by default.

Addresses: #368
Supersedes: #388

An example output from backtrace implementation using libbacktrace looks like this:

<VALIDATION>[ERROR]: #0 0x7fb0800bbf37 in (urContextRelease) (/home/kswiecic/dev/sycl_workspace/unified-runtime/source/loader/ur_libapi.cpp:745)
<VALIDATION>[ERROR]: #1 0x55d4bacd942f in (valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1::operator()() const) (/home/kswiecic/dev/sycl_workspace/unified-runtime/test/layers/validation/leaks_mt.cpp:40)
<VALIDATION>[ERROR]: #2 0x55d4bacd92ac in (void std::__invoke_impl<void, valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1>(std::__invoke_other, valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1&&)) (/usr/include/c++/11/bits/invoke.h:61)
<VALIDATION>[ERROR]: #3 0x55d4bacd923c in (std::__invoke_result<valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1>::type std::__invoke<valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1>(valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1&&)) (/usr/include/c++/11/bits/invoke.h:96)
<VALIDATION>[ERROR]: #4 0x55d4bacd9214 in (void std::thread::_Invoker<std::tuple<valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1> >::_M_invoke<0ul>(std::_Index_tuple<0ul>)) (/usr/include/c++/11/bits/std_thread.h:253)
<VALIDATION>[ERROR]: #5 0x55d4bacd91e4 in (std::thread::_Invoker<std::tuple<valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1> >::operator()()) (/usr/include/c++/11/bits/std_thread.h:260)
<VALIDATION>[ERROR]: #6 0x55d4bacd9148 in (std::thread::_State_impl<std::thread::_Invoker<std::tuple<valDeviceTestMultithreaded_testUrContextReleaseLeakMt_Test::TestBody()::$_1> > >::_M_run()) (/usr/include/c++/11/bits/std_thread.h:211)
<VALIDATION>[ERROR]: #7 0x7fb07fb4fb42 in (start_thread) (????????)
<VALIDATION>[ERROR]: #8 0x7fb07fbe19ff in (????????) (????????)

@kswiecicki kswiecicki changed the title Validation backtrace libbacktrace Add validation backtrace libbacktrace Mar 30, 2023
@kswiecicki kswiecicki force-pushed the validation-backtrace-libbacktrace branch from 7fa4aca to ca0c7a7 Compare March 30, 2023 11:08
@pbalcer
Copy link
Contributor

pbalcer commented Mar 30, 2023

is it possible to somehow demangle the symbols?

@kswiecicki kswiecicki force-pushed the validation-backtrace-libbacktrace branch 3 times, most recently from 68a7914 to 7f03b42 Compare March 31, 2023 11:03
@kswiecicki
Copy link
Contributor Author

is it possible to somehow demangle the symbols?

I've demangled the symbols with abi::__cxa_demangle. Since Windows backtrace looks decent and abi::__cxa_demangle is UNIX specific, I've set up the VAL_USE_LIBBACKTRACE_BACKTRACE to be a possible option only on UNIX platforms.

@pbalcer
Copy link
Contributor

pbalcer commented Mar 31, 2023

I also had a thought about not showing ur-internal functions. Would it be possible to detect the first loader function, so this:
<VALIDATION>[ERROR]: /home/kswiecic/dev/sycl_workspace/unified-runtime/source/loader/ur_libapi.cpp:745 (urContextRelease) [0x7f1cd434878f]
and skip it and everything above it?

@kswiecicki kswiecicki force-pushed the validation-backtrace-libbacktrace branch 2 times, most recently from 8dd984f to 179d800 Compare April 3, 2023 10:17
@kswiecicki
Copy link
Contributor Author

I also had a thought about not showing ur-internal functions. Would it be possible to detect the first loader function, so this: <VALIDATION>[ERROR]: /home/kswiecic/dev/sycl_workspace/unified-runtime/source/loader/ur_libapi.cpp:745 (urContextRelease) [0x7f1cd434878f] and skip it and everything above it?

Done. I'm filtering out the backtrace lines before the occurrence of the "ur_libapi.cpp" substring.

@kswiecicki kswiecicki force-pushed the validation-backtrace-libbacktrace branch 2 times, most recently from 165291d to 5d32ce4 Compare April 5, 2023 11:15
@kswiecicki kswiecicki marked this pull request as ready for review April 5, 2023 11:48
@kswiecicki
Copy link
Contributor Author

@pbalcer I've changed the format of the backtrace to resemble the format from the address sanitizer backtrace.

@kswiecicki kswiecicki force-pushed the validation-backtrace-libbacktrace branch from 5d32ce4 to f2031e7 Compare April 5, 2023 11:52
@pbalcer pbalcer merged commit 245c498 into oneapi-src:main Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants