Replace "backward" stack trace with absl::Stacktrace.#5723
Replace "backward" stack trace with absl::Stacktrace.#5723dnoe merged 11 commits intoenvoyproxy:masterfrom
Conversation
Use the absl::Stacktrace library along with absl::Symbolize to generate symbolized stack traces without requiring any external tool or post processing. Remove the external dependency on "backward" library. This deprecates stack_decode.py, which is removed. References to the stack_decode.py process are removed from README. Signed-off-by: Dan Noé <dpn@google.com>
|
Do you know what's up with CI? Maybe a local test with asan or tsan might help? I didn't see anything in the log. |
|
/retest |
|
🔨 rebuilding |
htuch
left a comment
There was a problem hiding this comment.
LGTM, do you have a before/after stack trace to compare?
source/server/backtrace.h
Outdated
| private: | ||
| static const int MAX_STACK_DEPTH = 64; | ||
| backward::StackTrace stack_trace_; | ||
| static constexpr int MAX_STACK_DEPTH = 64; |
There was a problem hiding this comment.
Nit: prefer moving to the newer Envoy convention of MaxStackDepth while mucking around here.
|
Investigating the CI failures. |
stack_depth_ wasn't zero initialized, it should be to make attempts to log a trace without first capturing a trace safe. Signed-off-by: Dan Noé <dpn@google.com>
|
Here's what they look like out of the box now: Having looked at this, I'm going to make one more change which is to include the address even if the symbol can be resolved by |
|
Can you show the output with a debug build? I'm hoping there will be line numbers. |
|
Sadly, there are not. Maybe with a future version of But, with the revised version where I print the decoded symbol and address, you can use addr2line on it and get the full information. I think this is probably the best compromise between providing useful information in the log out of the box, and providing the ability to get more information as needed later with |
Signed-off-by: Dan Noé <dpn@google.com>
|
/review @jmarantz |
bazel/README.md
Outdated
| than resolved symbols. | ||
| than resolved symbols. If the symbols were resolved, the address is also included at | ||
| the end of the line. It can be used with a debugging tool like `addr2line` to | ||
| get a precise line number if the required debugging info is available. |
There was a problem hiding this comment.
Can you add a suggested bazel --run_under=.... snippet describing how we can get line numbers?
There was a problem hiding this comment.
addr2line isn't a pass through by itself, although I implemented such a functionality into stack_decode.py. If you think it'll actually be useful I can modify stack_decode.py to work with the new format backtraces rather than eliminate it. Then you'll be able to use bazel --run_under= like before.
Alternatively, I can just write instructions for manually invoking addr2line with the right args and the addresses of interest (it just won't be a --run_under=).
I have a mild preference for the latter (and let stack_decode.py die), WDYT?
There was a problem hiding this comment.
I feel like run_under is easier to use unless addr2line is destructive to lines that are not part of stack traces. What's the reason you prefer to ask users to do this manually?
There was a problem hiding this comment.
Yeah, let's revive stack_decode.py. Sorry about the futz here, but I love my line numbers! :D
There was a problem hiding this comment.
No worries! I didn't think anyone was using it! Happy to fix it up to get the best of both worlds.
There was a problem hiding this comment.
So, revert this doc change? The previous flow still works, yeah? So the additional detail is not strictly necessary.
There was a problem hiding this comment.
The flow is slightly different. Previously, stack_decode.py autodetected the object file name from the log, because backward had this information and we could log it. But we don't have it anymore and the executable file needs to be passed in all circumstances so the usage details of stack_decode.py changed slightly. I'm going to update the doc now that mac CI is confirmed to be passing.
Signed-off-by: Dan Noé <dpn@google.com>
|
New output post stack_decode.py: Function names come directly from |
Signed-off-by: Dan Noé <dpn@google.com>
|
@htuch I'm not sure why |
Signed-off-by: Dan Noé <dpn@google.com>
|
mac build fails on //test/extensions/filters/listener/proxy_protocol:proxy_protocol_test I suspect this is a flake. /retest |
|
🔨 rebuilding |
Signed-off-by: Dan Noé <dpn@google.com>
|
@htuch this is ready for a senior maintainer pass. |
|
@dnoe the |
htuch
left a comment
There was a problem hiding this comment.
LGTM, but needs master merge and some Python nit picking.
tools/stack_decode.py
Outdated
| stdout=subprocess.PIPE) | ||
| output_stdout, _ = addr2line.communicate(piped_input) | ||
| return output_stdout.split("\n") | ||
| output_stdout, _ = addr2line.communicate() |
There was a problem hiding this comment.
Nit: I think we could just use subprocess.check_output here now to simplify.
| else: | ||
| decode_stacktrace_log(sys.stdin) | ||
| print "Usage (execute subprocess): stack_decode.py executable_file [additional args]" | ||
| print "Usage (read from stdin): stack_decode.py -s executable_file" |
There was a problem hiding this comment.
Done; will sys.exit(0) in stdin use case.
tools/stack_decode.py
Outdated
| return file_and_line_number | ||
|
|
||
|
|
||
| def trim_from_start(string, trim): |
There was a problem hiding this comment.
Nit: prefer not using string here, since it can be confused with https://docs.python.org/3/library/string.html
There was a problem hiding this comment.
Replaced the whole thing with re.sub.
tools/stack_decode.py
Outdated
| def trim_from_start(string, trim): | ||
| if string.startswith(trim): | ||
| return string[len(trim):] | ||
| else: |
There was a problem hiding this comment.
Nit: no need for else, just fall-thru
There was a problem hiding this comment.
Replaced the whole thing with re.sub.
tools/stack_decode.py
Outdated
| def trim_proc_cwd(file_and_line_number): | ||
| # Try the longer trim first, it will leave the string untouched if it doesn't | ||
| # match. | ||
| file_and_line_number = trim_from_start(file_and_line_number, "/proc/self/cwd/./") |
There was a problem hiding this comment.
Why not do a regex search and replace with re.sub or the like? Performance is likely fine here.
There was a problem hiding this comment.
Excellent idea, thanks.
Signed-off-by: Dan Noé <dpn@google.com>
|
|
|
/retest |
|
🔨 rebuilding |
Description: Use the absl::Stacktrace library along with absl::Symbolize to generate symbolized stack traces without requiring any external tool or post processing. Remove the external dependency on "backward" library. The stack_decode.py script can still be used to obtain additional information, notably file and line numbers. See bazel/README.md for revised usage instructions. Risk Level: Low (may break tooling that interpreted stack traces in logs) Testing: bazel test //test/... , manually examined symbolized backtrace in killed binary. Docs Changes: Changed bazel/README.md Release Notes: Usage details of the stack_decode.py script have changed. Stack traces should include decoded names without it when the binary has appropriate debugging symbols. The script can be used to obtain file and line numbers, see bazel/README.md for details. Signed-off-by: Dan Noé <dpn@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
|
@dnoe before your changes, If I want to test a new arch, I just added in Could you point me where I should add in the new code? I have successfully compiled the envoy in s390x, but failed to run with this error. Thanks. |
| def _com_github_bombela_backward(): | ||
| _repository_impl( | ||
| name = "com_github_bombela_backward", | ||
| build_file = "@envoy//bazel/external:backward.BUILD", |
There was a problem hiding this comment.
I just noticed that https://github.com/envoyproxy/envoy/blob/master/bazel/external/backward.BUILD is still in the codebase. This can be removed now I believe @dnoe
Description:
Use the absl::Stacktrace library along with absl::Symbolize to generate
symbolized stack traces without requiring any external tool or post
processing.
Remove the external dependency on "backward" library.
This deprecates stack_decode.py, which is removed. References to the
stack_decode.py process are removed from README.
Risk Level: Low (may break tooling that interpreted stack traces in logs)
Testing: bazel test //test/... , manually examined symbolized backtrace in killed binary.
Docs Changes: Changed bazel/README.md
Release Notes: The stack_decode.py script is removed, stack traces should include decoded names without it when the binary has appropriate debugging symbols.
Signed-off-by: Dan Noé dpn@google.com