8164091: VM fails during startup with "assert(resolved_method->method_holder()->is_linked()) failed: must be linked"

Don't throw java_lang_VirtualMachineError during VM initialization.

Reviewed-by: zmajo, dlong, dholmes
This commit is contained in:
Tobias Hartmann 2016-08-17 08:19:06 +02:00
parent 72dcc9193e
commit be08874935
2 changed files with 19 additions and 4 deletions

View File

@ -54,6 +54,7 @@
#include "runtime/compilationPolicy.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/init.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/relocator.hpp"
#include "runtime/sharedRuntime.hpp"
@ -1015,7 +1016,14 @@ address Method::make_adapters(methodHandle mh, TRAPS) {
// so making them eagerly shouldn't be too expensive.
AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
if (adapter == NULL ) {
THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
if (!is_init_completed()) {
// Don't throw exceptions during VM initialization because java.lang.* classes
// might not have been initialized, causing problems when constructing the
// Java exception object.
vm_exit_during_initialization("Out of space in CodeCache for adapters");
} else {
THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
}
}
if (mh->is_shared()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 8026949
* @bug 8026949 8164091
* @summary Test ensures correct VM output during startup
* @library /testlibrary
* @modules java.base/jdk.internal.misc
@ -45,7 +45,14 @@ public class StartupOutput {
pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:+DisplayVMOutputToStdout", "-version");
out = new OutputAnalyzer(pb.start());
out.shouldNotContain("no space to run compilers");
out.shouldHaveExitValue(0);
pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:ReservedCodeCacheSize=1770K", "-XX:InitialCodeCacheSize=4K", "-version");
out = new OutputAnalyzer(pb.start());
// The VM should not crash but may return an error message because we don't have enough space for adapters
int exitCode = out.getExitValue();
if (exitCode != 1 && exitCode != 0) {
throw new Exception("VM crashed with exit code " + exitCode);
}
}
}