-
Notifications
You must be signed in to change notification settings - Fork 818
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
AsyncGetCallTrace replacement #795
Comments
Added new stack walker that does not depend on AGCT as an optional feature. With this option, async-profiler collects mixed stack traces that have Java and native frames interleaved. The total stack depth is controlled with |
As a part of this work, DWARF unwinding has been implemented for ARM64 (it was previously available only on x86_64). |
It's worth mentioning that new stack walker is fully enclosed by the crash protection based on |
Closing the issue as solved. Further improvements will be done in the context of separate issues. |
Thank you @apangin. |
Background
AsyncGetCallTrace
(AGCT) is a non-standard extension of HotSpot JVM to obtain Java stack traces outside safepoints. async-profiler has been relying on AGCT heavily, it even got its name after this function.In the meantime, being non-API,
AsyncGetCallTrace
was never supported in OpenJDK well enough: it did not receive enough testing, it was broken several times even in minor JDK updates, e.g. JDK-8307549.AsyncGetCallTrace
is notorious for inability to walk Java stack in different corner cases. There is a long-standing bug JDK-8178287 with several examples. But the worst thing is thatAsyncGetCallTrace
can crash JVM, and there is no reliable way to get around this outside the JVM.Furthermore,
AsyncGetCallTrace
has limited capabilities. It does not provide information about Java frame type (interpreted/compiled/inlined). It skips all non-Java frames, so it's impossible to see JNI or JVM internal frames in the middle of the call stack.It was previously proposed in #66 to re-implement stack walking in async-profiler without the problematic API. However, as async-profiler got workarounds for different shortcomings of
AsyncGetCallTrace
, the re-implementation was postponed. But after years, we still see issues with AGCT from time to time, including random crashes and missing stack traces.Proposal
Get rid of the dependency on
AsyncGetCallTrace
entirely, at least, for HotSpot JVM. LeverageVMStructs
for getting offsets of the HotSpot structures essential for stack walking. Implement stack walking externally like Serviceability Agent does.Requirements
Target platforms
The implementation targets HotSpot JVM on Linux and macOS, both x64 and ARM64.
It is not required to provide new stack walker for other platforms and other JVM implementations.
Example
This is how mixed stack traces may look on a flame graph:
The text was updated successfully, but these errors were encountered: