Skip to content

Commit

Permalink
8312596: Null pointer access in Compile::TracePhase::~TracePhase afte…
Browse files Browse the repository at this point in the history
…r JDK-8311976

Reviewed-by: chagedorn, dlong, shade
  • Loading branch information
ashu-mehra authored and shipilev committed Aug 1, 2023
1 parent ec2f38f commit 7ba8c69
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4332,10 +4332,13 @@ void Compile::record_failure(const char* reason) {

Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator)
: TraceTime(name, accumulator, CITime, CITimeVerbose),
_compile(nullptr), _log(nullptr), _phase_name(name), _dolog(CITimeVerbose)
_compile(Compile::current()),
_log(nullptr),
_phase_name(name),
_dolog(CITimeVerbose)
{
assert(_compile != nullptr, "sanity check");
if (_dolog) {
_compile = Compile::current();
_log = _compile->log();
}
if (_log != nullptr) {
Expand All @@ -4353,7 +4356,7 @@ Compile::TracePhase::~TracePhase() {
}

if (VerifyIdealNodeCount) {
Compile::current()->print_missing_nodes();
_compile->print_missing_nodes();
}
#endif

Expand Down
37 changes: 37 additions & 0 deletions test/hotspot/jtreg/compiler/c2/TestPrintIdealNodeCount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8312596
* @requires vm.debug == true & vm.compiler2.enabled
* @summary Run with -Xcomp -XX:-TieredCompilation to force C2 compilations to test -XX:+PrintIdealNodeCount in debug builds.
*
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+PrintIdealNodeCount compiler.c2.TestPrintIdealNodeCount
*/
package compiler.c2;

public class TestPrintIdealNodeCount {
public static void main(String[] args) {
}
}

1 comment on commit 7ba8c69

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.