United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7174884 C1: failures after 7171890: assert(cur_state != NULL) failed: state_before must be set
JDK-7174884 : C1: failures after 7171890: assert(cur_state != NULL) failed: state_before must be set

Details
Type:
Bug
Submit Date:
2012-06-06
Status:
Closed
Updated Date:
2013-09-04
Project Name:
JDK
Resolved Date:
2012-06-16
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
hs23
Fixed Versions:
hs24 (b14)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (C:\jprt\T\P1\092016.rwestrel\s\src\share\vm\c1\c1_GraphBuilder.cpp:2128), pid=9448, tid=4196
#  assert(cur_state != NULL) failed: state_before must be set
#
# JRE version: 7.0_04-b20
# Java VM: Java HotSpot(TM) Client VM (24.0-b12-internal-201206050920.rwestrel.hotspot-fastdebug compiled mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/e1635876b206
                                     
2012-06-07
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/e1635876b206
                                     
2012-06-29
EVALUATION

It's very easy to reproduce with the jruby.jar and CTW:

cthaling@intelsdv01:~/mlvm/jruby$ java -client -XX:+CompileTheWorld -Xbootclasspath/p:lib/jruby.jar -XX:CompileTheWorldStartAt=458 -XX:+ShowMessageBoxOnError
CompileTheWorld : Compiling all classes in /home/cthaling/mlvm/jruby/lib/jruby.jar

Preloading failed for (380) com/martiansoftware/nailgun/builtins/NGVersion
Preloading failed for (397) jline/AnsiWindowsTerminal
CompileTheWorld (458) : jnr/constants/Constant
CompileTheWorld (459) : jnr/constants/ConstantSet$ConstantIterator
CompileTheWorld (460) : jnr/constants/ConstantSet
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/c1_GraphBuilder.cpp:2128
==============================================================================
Unexpected Error
------------------------------------------------------------------------------
Internal Error at c1_GraphBuilder.cpp:2128, pid=6669, tid=7
assert(cur_state != NULL) failed: state_before must be set

Do you want to debug the problem?

To debug, run 'dbx - 6669'; then switch to thread 7
Enter 'yes' to launch dbx automatically (PATH must include dbx)
Otherwise, press RETURN to abort...
==============================================================================

The Canonicalizer in append_with_bci returns an InstanceOf node which doesn't have a state_before:

(dbx) p instr->print()
__bci__use__tid____instr____________________________________
. 6    0    i23    isInstance(a13, a15)

instr->print() = (void)
(dbx) p *instr         
*instr = {
   _id                 = 23
   _printable_bci      = 6
   _use_count          = 0
   _pin_state          = 8192
   _type               = 0x8578430
   _next               = (nil)
   _subst              = (nil)
   _operand            = 0xffffffff
   _flags              = 515U
   _state_before       = 0x859f7b8
   _exception_state    = (nil)
   _exception_handlers = (nil)
}
(dbx) p i1->print()
__bci__use__tid____instr____________________________________
. 6    0    i24    instanceof(a15) jnr/constants/Constant

i1->print() = (void)
(dbx) p *i1         
*i1 = {
   _id                 = 24
   _printable_bci      = 6
   _use_count          = 0
   _pin_state          = 8192
   _type               = 0x8578430
   _next               = (nil)
   _subst              = (nil)
   _operand            = 0xffffffff
   _flags              = 131072U
   _state_before       = (nil)
   _exception_state    = (nil)
   _exception_handlers = (nil)
}

It seems we are passing the wrong state to InstanceOf.  This line:

       InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state());

should be:

       InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state_before());
                                     
2012-06-06
SUGGESTED FIX

diff --git a/src/share/vm/c1/c1_Canonicalizer.cpp b/src/share/vm/c1/c1_Canonicalizer.cpp
--- a/src/share/vm/c1/c1_Canonicalizer.cpp
+++ b/src/share/vm/c1/c1_Canonicalizer.cpp
@@ -466,7 +466,7 @@
       if (t->is_klass()) {
         // substitute cls.isInstance(obj) of a constant Class into
         // an InstantOf instruction
-        InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state());
+        InstanceOf* i = new InstanceOf(t->as_klass(), x->argument_at(1), x->state_before());
         set_canonical(i);
         // and try to canonicalize even further
         do_InstanceOf(i);
                                     
2012-06-06



Hardware and Software, Engineered to Work Together