Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8280684: JfrRecorderService failes with guarantee(num_written > 0) wh…
…en no space left on device.

Reviewed-by: mgronlun
  • Loading branch information
tkiriyama authored and Markus Grönlund committed Feb 25, 2022
1 parent 3efd6aa commit 9471f24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -554,14 +554,16 @@ void JfrJavaSupport::throw_runtime_exception(const char* message, TRAPS) {

void JfrJavaSupport::abort(jstring errorMsg, JavaThread* t) {
DEBUG_ONLY(check_java_thread_in_vm(t));

ResourceMark rm(t);
const char* const error_msg = c_str(errorMsg, t);
if (error_msg != NULL) {
log_error(jfr, system)("%s",error_msg);
abort(c_str(errorMsg, t));
}

void JfrJavaSupport::abort(const char* error_msg, bool dump_core /* true */) {
if (error_msg != nullptr) {
log_error(jfr, system)("%s", error_msg);
}
log_error(jfr, system)("%s", "An irrecoverable error in Jfr. Shutting down VM...");
vm_abort();
vm_abort(dump_core);
}

JfrJavaSupport::CAUSE JfrJavaSupport::_cause = JfrJavaSupport::VM_ERROR;
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -101,6 +101,7 @@ class JfrJavaSupport : public AllStatic {

// critical
static void abort(jstring errorMsg, TRAPS);
static void abort(const char* error_msg, bool dump_core = true);
static void uncaught_exception(jthrowable throwable, JavaThread* t);

// asserts
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/jfr/writers/jfrStreamWriterHost.inline.hpp
Expand Up @@ -25,8 +25,8 @@
#ifndef SHARE_JFR_WRITERS_JFRSTREAMWRITERHOST_INLINE_HPP
#define SHARE_JFR_WRITERS_JFRSTREAMWRITERHOST_INLINE_HPP

#include "jfr/jni/jfrJavaSupport.hpp"
#include "jfr/writers/jfrStreamWriterHost.hpp"

#include "runtime/os.hpp"

template <typename Adapter, typename AP>
Expand Down Expand Up @@ -77,6 +77,9 @@ inline void StreamWriterHost<Adapter, AP>::write_bytes(const u1* buf, intptr_t l
while (len > 0) {
const unsigned int nBytes = len > INT_MAX ? INT_MAX : (unsigned int)len;
const ssize_t num_written = os::write(_fd, buf, nBytes);
if (errno == ENOSPC) {
JfrJavaSupport::abort("Failed to write to jfr stream because no space left on device", false);
}
guarantee(num_written > 0, "Nothing got written, or os::write() failed");
_stream_pos += num_written;
len -= num_written;
Expand Down

5 comments on commit 9471f24

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbachorik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 9471f24 Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbachorik Could not automatically backport 9471f24c to openjdk/jdk17u due to conflicts in the following files:

  • src/hotspot/share/jfr/writers/jfrStreamWriterHost.inline.hpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk17u:

$ git checkout -b jbachorik-backport-9471f24c
$ git fetch --no-tags https://git.openjdk.java.net/jdk 9471f24ca191832669a13e5a1ea73f7097a25927
$ git cherry-pick --no-commit 9471f24ca191832669a13e5a1ea73f7097a25927
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 9471f24ca191832669a13e5a1ea73f7097a25927'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u with the title Backport 9471f24ca191832669a13e5a1ea73f7097a25927.

@jbachorik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 9471f24 Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbachorik Could not automatically backport 9471f24c to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
  • src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
  • src/hotspot/share/jfr/writers/jfrStreamWriterHost.inline.hpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b jbachorik-backport-9471f24c
$ git fetch --no-tags https://git.openjdk.java.net/jdk 9471f24ca191832669a13e5a1ea73f7097a25927
$ git cherry-pick --no-commit 9471f24ca191832669a13e5a1ea73f7097a25927
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 9471f24ca191832669a13e5a1ea73f7097a25927'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 9471f24ca191832669a13e5a1ea73f7097a25927.

Please sign in to comment.