RFR: 8284828: Use `os::ThreadCrashProtection` to protect AsyncGetCallTrace from crashing [v8]

Johannes Bechberger duke at openjdk.java.net
Thu Apr 14 14:56:29 UTC 2022


> Move the AsyncGetCallTrace method implementation into a separate method and wrap its call in non-assert compilation mode in `os::ThreadCrashProtection` like it is done in [JFR](https://github.com/openjdk/jdk/blob/965ea8d9cd29aee41ba2b1b0b0c67bb67eca22dd/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp#L165).
> This prevents AsyncGetCallTrace from crashing on segmentation faults (but not on `guarantee`s).
> 
> If a crash is observed, then the `num_frames` field of the trace is set to `ticks_unknown_state` (-7) to signal a state that cannot be properly handled. `ticks_unknown_state` is currently also used for signaling unknown thread states but this should not be a problem, as the semantic is the same. If `num_frames` already has an error code then this error code is not changed. This helps to distinguish between errors in walking threads in Java and non-Java mode, as `num_frames` is set there before the walking to the appropriate error code.
> 
> _Thanks for @tstuefe for suggesting this._

Johannes Bechberger has updated the pull request incrementally with one additional commit since the last revision:

  Do not call JavaThread::thread_from_jni_environment
  
  Calling JavaThread::thread_from_jni_environment for
  a terminated thread might cause the aquisition of a lock.
  Calling JavaThread::current does not have this problem
  and AsyncGetCallTrace can only be called on the current
  thread anyway.

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8225/files
  - new: https://git.openjdk.java.net/jdk/pull/8225/files/d003ce09..b16e85d2

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=8225&range=07
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=8225&range=06-07

  Stats: 4 lines in 1 file changed: 0 ins; 1 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8225.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8225/head:pull/8225

PR: https://git.openjdk.java.net/jdk/pull/8225


More information about the hotspot-dev mailing list