-
Notifications
You must be signed in to change notification settings - Fork 113
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 support for human-readable stacktraces #785
Conversation
On some platforms libc provides execinfo.h, which allows printing the stack. We can use this feature to add stacktrace information to the signal handlers of fatal errors such as SIGSEGV or SIGBUS.
This only works on macos for now. the regex will have to be adjusted for linux.
(especially in linux)
Using backward-cpp we get proper backtraces on mac and backtraces+src on linux. This fulfills #733 (but with the dependency on a new submodule)
(I realize that I am missing somewhere still an |
If backward is not desired or available let's fall back to our own (simple) implementation. Still wip since linux backtrace format needs to be understood
and minor improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some comments/questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this PR locally and seems to be working fine!
set(options CXX) | ||
cmake_parse_arguments(nrn_check_include_files "${options}" "" "" ${ARGN}) | ||
if(${nrn_check_include_files_CXX}) | ||
check_include_file_cxx(${filename} ${variable}) | ||
else() | ||
check_include_files(${filename} ${variable}) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to clarify : this is currently not called with CXX option but only for C, right?
src/oc/hoc.c
Outdated
char* symbol = malloc(sizeof(char)*funcname_size); | ||
char* offset = malloc(sizeof(char)*10); | ||
char* funcname = malloc(sizeof(char)*funcname_size); | ||
void* addr = NULL; | ||
// get void*'s for maximum last 16 entries on the stack | ||
size = backtrace(frames, nframes); | ||
|
||
// print out all the frames to stderr | ||
Fprintf(stderr, "Backtrace:\n"); | ||
bt_strings = backtrace_symbols(frames, size); | ||
if (bt_strings) { | ||
size_t i; | ||
for(i = 2; i < size; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some clarification here about offset=10, i=2
etc would be helpful.
Just for the record, this is how I have tested this on BB5:
and with binutils support as:
With python I wasn't able to get nice tracebacks because of the issue #797. But if I disable #797 can be handled separately. |
* Tweak NVHPC warning suppressions. * Emit nrn_pragma_{acc,omp}(...) macros. (#780) * Use cnrn_target_ wrappers instead of acc_ API. * GPU code generation improvements (#782) * Fix NVHPC + OpenMP ~ OpenACC compilation (#784) * Add EIGEN_DEVICE_FUNC to header to fix a compilation warning. * Fudge partialPivLu<N> for NVHPC + OpenMP without OpenACC. * Transfer ml only if cell is not artificial. (#785) * Update Eigen to include OpenMP fixes. (#787, #789) Co-authored-by: Nicolas Cornu <nicolas.cornu@epfl.ch> Co-authored-by: Pramod Kumbhar <pramod.kumbhar@epfl.ch>
This PR (see issue #733) uses the backtrace-cpp library to give rich backtrace information on segfaults and other terminating signals.
To get a nice stacktrace on a segfault with full source information (on linux) neuron, one has to enable the feature and provide paths to libbfd (part of binutils):
Here is how a backtrace without backward-cpp looks like:
and here is how it looks like with backward-cpp: