[jdk17u-dev] RFR: 8295974: jni_FatalError and Xcheck:jni warnings should print the native stack when there are no Java frames

Richard Reingruber rrich at openjdk.org
Tue May 16 13:58:00 UTC 2023


On Tue, 16 May 2023 13:37:04 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Just skimmed over this. Pre-existing, and should be fixed in upstream, but is this always guaranteed to run on an attached thread that has an active resource area? Should the buffer not rather allocated from the RA of the thread given ReportJNIFatalError instead from the RA of the current thread?

Are you referring to this allocation: https://github.com/openjdk/jdk17u-dev/pull/1328/files#diff-112070300c35ec514e93e1880e86bbf8d229bb51d1cb63d1ea6f49319cb66a88R2294 ?

If so then then the assertion a few lines above checks just this.

```c++
  static inline void ReportJNIFatalError(JavaThread* thr, const char *msg) {
    tty->print_cr("FATAL ERROR in native method: %s", msg);
    thr->print_jni_stack();
    os::abort(true);
  }


```c++
void JavaThread::print_jni_stack() {
  assert(this == JavaThread::current(), "Can't print stack of other threads");
  if (!has_last_Java_frame()) {
    ResourceMark rm(this);
    char* buf = NEW_RESOURCE_ARRAY_RETURN_NULL(char, O_BUFLEN);
    if (buf == nullptr) {
      tty->print_cr("Unable to print native stack - out of memory");
      return;
    }

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

PR Comment: https://git.openjdk.org/jdk17u-dev/pull/1328#issuecomment-1549722057


More information about the jdk-updates-dev mailing list