JDK-8028274 : assert: "stringStream is re-allocated with a different ResourceMark" w/ -XX:+PrintInlining
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs25,9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-11-13
  • Updated: 2016-03-29
  • Resolved: 2016-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Duplicate :  
Description
#  Internal Error (/Users/vladimir/ws/hotspot-comp/src/share/vm/utilities/ostream.cpp:326), pid=20751, tid=22019
#  assert(rm == NULL || Thread::current()->current_resource_mark() == rm) failed: stringStream is re-allocated with a different ResourceMark
#
# JRE version: OpenJDK Runtime Environment (8.0) (build 1.8.0-internal-vladimir_2013_10_08_18_34-b00)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b58-internal-debug mixed mode bsd-amd64 compressed oops)

V  [libjvm.dylib+0xe2b6df]  VMError::report(outputStream*)+0x1307
V  [libjvm.dylib+0xe2cb9e]  VMError::report_and_die()+0x560
V  [libjvm.dylib+0x570697]  report_vm_error(char const*, int, char const*, char const*)+0xc7
V  [libjvm.dylib+0xbd9b01]  stringStream::write(char const*, unsigned long)+0x13d
V  [libjvm.dylib+0xbdd493]  outputStream::print(char const*, ...)+0x1d7
V  [libjvm.dylib+0xd59601]  Symbol::print_symbol_on(outputStream*) const+0x77
V  [libjvm.dylib+0xb3032e]  Method::print_short_name(outputStream*)+0x80
V  [libjvm.dylib+0x418fff]  ciMethod::print_short_name(outputStream*)+0xdf
V  [libjvm.dylib+0x4ef7d1]  CompileTask::print_inlining(outputStream*, ciMethod*, int, int, char const*)+0x203
V  [libjvm.dylib+0x3d1559]  Compile::print_inlining(ciMethod*, int, int, char const*)+0x79
V  [libjvm.dylib+0x295550]  InlineTree::print_inlining(ciMethod*, int, bool) const+0x128
V  [libjvm.dylib+0x29863e]  InlineTree::ok_to_inline(ciMethod*, JVMState*, ciCallProfile&, WarmCallInfo*, bool&)+0x6b6
V  [libjvm.dylib+0x622333]  Compile::call_generator(ciMethod*, int, bool, JVMState*, bool, float, ciKlass*, bool, bool)+0x99d
V  [libjvm.dylib+0x3cdd68]  CallGenerator::for_method_handle_inline(JVMState*, ciMethod*, ciMethod*, bool&)+0x23e
V  [libjvm.dylib+0x3ce84d]  CallGenerator::for_method_handle_call(JVMState*, ciMethod*, ciMethod*, bool)+0xe9
V  [libjvm.dylib+0x621fb3]  Compile::call_generator(ciMethod*, int, bool, JVMState*, bool, float, ciKlass*, bool, bool)+0x61d
V  [libjvm.dylib+0x6236e4]  Parse::do_call()+0x718
Comments
The ResourceMarks which are in the way are in Symbol::print_symbol_on() and Method::print_short_name(). Maybe there are enough other ResourceMarks so we can omit them? The assertion disappears if they get removed.
10-08-2015

It's not safe to call methods allocating their own ResourceMark with stringStream, because possible internal buffer reallocation isn't safe then: it shortens lifetime of the buffer and future usages of stringStream can see corrupted buffer. Call stack: stringStream::write(char const*, unsigned long)+0x13d outputStream::print(char const*, ...)+0x1d7 Symbol::print_symbol_on(outputStream*) const+0x77 Method::print_short_name(outputStream*)+0x80 ciMethod::print_short_name(outputStream*)+0xdf CompileTask::print_inlining(outputStream*, ciMethod*, int, int, char const*)+0x203 Compile::print_inlining(ciMethod*, int, int, char const*)+0x79 ... src/share/vm/opto/compile.hpp: void print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) { stringStream ss; CompileTask::print_inlining(&ss, method, inline_level, bci, msg); print_inlining_stream()->print(ss.as_string()); } src/share/vm/oops/method.cpp: void Method::print_short_name(outputStream* st) { ResourceMark rm; ... src/share/vm/oops/symbol.cpp: void Symbol::print_symbol_on(outputStream* st) const { ResourceMark rm; st = st ? st : tty; st->print("%s", as_quoted_ascii()); } src/share/vm/utilities/ostream.cpp: void stringStream::write(const char* s, size_t len) { size_t write_len = len; // number of non-null bytes to write size_t end = buffer_pos + len + 1; // position after write and final '\0' if (end > buffer_length) { if (buffer_fixed) { ... } else { ... assert(rm == NULL || Thread::current()->current_resource_mark() == rm, "stringStream is re-allocated with a different ResourceMark"); buffer = NEW_RESOURCE_ARRAY(char, end); strncpy(buffer, oldbuf, buffer_pos); buffer_length = end;
13-11-2013

ILW = MLH (P4) I = M: possibly corrupts -XX:+PrintInlining output L = L: observed only with diagnostic flag -XX:+PrintInlining W = H: no workaround
13-11-2013