-
Notifications
You must be signed in to change notification settings - Fork 8k
tests: bluetooth: tester: Print backtrace on crash in native-sim build #97135
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
base: main
Are you sure you want to change the base?
Conversation
when figured out on how to pass |
61abb6e
to
bff0cbc
Compare
tests/bluetooth/tester/src/main.c
Outdated
} | ||
LOG_INF("=================================="); | ||
|
||
free(strings); |
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.
Given that we do a free
here, I guess backtrace_symbols
is doing a malloc?
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.
yes, however I could use backtrace_symbols_fd() instead which doesn't use heap
bff0cbc
to
ffa5d45
Compare
int nptrs; | ||
|
||
LOG_ERR("SEGMENTATION FAULT (address %p)", si->si_addr); | ||
nptrs = backtrace(buffer, BACKTRACE_BUF_SIZE); |
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.
Consider adding a check if nptrs == BACKTRACE_BUF_SIZE
which may indicate that the output was truncated, and we could add a log entry or something to let us know that BACKTRACE_BUF_SIZE
may need to be increased
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.
yeah, I'll add this, however BACKTRACE_BUF_SIZE is 100 :)
tests/bluetooth/tester/src/main.c
Outdated
|
||
LOG_ERR("SEGMENTATION FAULT (address %p)", si->si_addr); | ||
nptrs = backtrace(buffer, BACKTRACE_BUF_SIZE); | ||
backtrace_symbols_fd(buffer, nptrs, 2); |
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.
backtrace_symbols_fd(buffer, nptrs, 2); | |
backtrace_symbols_fd(buffer, nptrs, STDERR_FILENO); |
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.
May need to inlcude unistd.h
for this
tests/bluetooth/tester/src/main.c
Outdated
sigemptyset(&sa.sa_mask); | ||
sa.sa_flags = SA_SIGINFO; | ||
|
||
(void)sigaction(SIGSEGV, &sa, NULL); |
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.
sigaction
may return an error; suggest to actually verify this and LOG if it happens
We may also want to return that error to main
and immediately stop the program if it fails to register?
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.
ERRORS
EFAULT act or oldact points to memory which is not a valid part of the process address space.
EINVAL An invalid signal was specified. This will also be generated if an attempt is made to change the action for SIGKILL or SIGSTOP, which cannot be caught or ignored.
so sigaction() won't fail here, and even if it would fail I don't think we should abort (it is just debug code after all)
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.
Might be worth having an assert for it. Our coding guidelines require us to test all error codes (not sure if the coding guidelines actually apply to tests/test applications as well)
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'll add warning log for this
ffa5d45
to
6c2bc0b
Compare
If Zephyr process was terminated due to segmentation fault print note and backtrace for debugging purposes. *** Booting Zephyr OS build v4.2.0-5260-g9a778a6beff7 *** [00:00:00.000,000] <dbg> bttester: tester_init: Initializing tester [00:00:00.000,000] <err> bttester_main: SEGMENTATION FAULT (address (nil)) zephyr/build/zephyr/zephyr.exe() [0x8049987] linux-gate.so.1(__kernel_rt_sigreturn+0x0) [0xf7f695b0] zephyr/build/zephyr/zephyr.exe() [0x804a8dc] zephyr/build/zephyr/zephyr.exe() [0x8049fc5] zephyr/build/zephyr/zephyr.exe() [0x80499fb] zephyr/build/zephyr/zephyr.exe() [0x80b2c24] zephyr/build/zephyr/zephyr.exe() [0x8060166] zephyr/build/zephyr/zephyr.exe() [0x80658ea] zephyr/build/zephyr/zephyr.exe() [0x80b9a45] /lib/libc.so.6(+0x72b20) [0xf7cd2b20] /lib/libc.so.6(+0xf8c58) [0xf7d58c58] Signed-off-by: Szymon Janc <[email protected]>
6c2bc0b
to
9f21fc4
Compare
|
If Zephyr process was terminated due to segmentation fault print note and backtrace for debugging purposes.