JDK-8207401 : [lworld] TestLWorld.java crashes java_lang_String::create_from_symbol
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: repo-valhalla
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-07-17
  • Updated: 2018-07-17
  • Resolved: 2018-07-17
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.
Other
repo-valhallaFixed
Related Reports
Relates :  
Description
Current thread (0x00007f4f6052a800):  JavaThread "MainThread" [_thread_in_vm, id=6971, stack(0x00007f4f36973000,0x00007f4f36a74000)]

Stack: [0x00007f4f36973000,0x00007f4f36a74000],  sp=0x00007f4f36a70ad0,  free space=1014k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x100118c]  java_lang_String::create_from_symbol(Symbol*, Thread*)+0x2c
V  [libjvm.so+0x1174d70]  JVM_GetLocalValueTypes+0x4c0
j  java.lang.Class.getLocalValueTypes0()[Ljava/lang/String;+0 java.base
j  java.lang.Class.getDeclaredValueTypeNames()Ljava/util/Set;+10 java.base
j  java.lang.System$2.getDeclaredValueTypeNames(Ljava/lang/Class;)Ljava/util/Set;+1 java.base
j  java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass()Ljava/lang/Class;+439 java.base
j  java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite()Ljava/lang/invoke/CallSite;+1 java.base
j  java.lang.invoke.LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;+31 java.base
j  java.lang.invoke.LambdaForm$DMH.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;+20 java.base
j  java.lang.invoke.LambdaForm$MH.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;+28 java.base
j  java.lang.invoke.BootstrapMethodInvoker.invoke(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+262 java.base
j  java.lang.invoke.CallSite.makeSite(Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/invoke/CallSite;+8 java.base
j  java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+6 java.base
j  java.lang.invoke.MethodHandleNatives.linkCallSite(Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+46 java.base
v  ~StubRoutines::call_stub
V  [libjvm.so+0xfdfd48]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x8c8
V  [libjvm.so+0xfdd271]  JavaCalls::call_static(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, Thread*)+0x1d1
V  [libjvm.so+0x1904175]  SystemDictionary::find_dynamic_call_site_invoker(Klass*, int, Handle, Symbol*, Symbol*, Handle*, Handle*, Thread*)+0x745
V  [libjvm.so+0x1364efe]  LinkResolver::resolve_dynamic_call(CallInfo&, int, Handle, Symbol*, Symbol*, Klass*, Thread*)+0x5e
V  [libjvm.so+0x1365473]  LinkResolver::resolve_invokedynamic(CallInfo&, constantPoolHandle const&, int, Thread*)+0x483
V  [libjvm.so+0x13695e0]  LinkResolver::resolve_invoke(CallInfo&, Handle, constantPoolHandle const&, int, Bytecodes::Code, Thread*)+0x180
V  [libjvm.so+0xfafcb1]  InterpreterRuntime::resolve_invokedynamic(JavaThread*)+0x291
V  [libjvm.so+0xfba558]  InterpreterRuntime::resolve_from_cache(JavaThread*, Bytecodes::Code)+0x108
j  compiler.valhalla.valuetypes.TestLWorld.<clinit>()V+48
v  ~StubRoutines::call_stub
V  [libjvm.so+0xfdfd48]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x8c8
V  [libjvm.so+0xf8035b]  InstanceKlass::call_class_initializer(Thread*)+0x19b
V  [libjvm.so+0xf827fe]  InstanceKlass::initialize_impl(Thread*)+0x54e
V  [libjvm.so+0xf82c4b]  InstanceKlass::initialize(Thread*)+0x8b
V  [libjvm.so+0x1787c68]  invoke(InstanceKlass*, methodHandle const&, Handle, bool, objArrayHandle, BasicType, objArrayHandle, bool, Thread*)+0x88
V  [libjvm.so+0x178d8f2]  Reflection::invoke_method(oop, Handle, objArrayHandle, Thread*)+0x222
V  [libjvm.so+0x116c40b]  JVM_InvokeMethod+0x22b
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 java.base
j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base
j  com.sun.javatest.regtest.agent.MainWrapper$MainThread.run()V+172
j  java.lang.Thread.run()V+11 java.base
v  ~StubRoutines::call_stub
V  [libjvm.so+0xfdfd48]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x8c8
V  [libjvm.so+0xfdbea7]  JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, Thread*)+0x477
V  [libjvm.so+0xfdc131]  JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, Thread*)+0xb1
V  [libjvm.so+0x114e3f6]  thread_entry(JavaThread*, Thread*)+0xb6
V  [libjvm.so+0x19600e7]  JavaThread::thread_main_inner()+0x287
V  [libjvm.so+0x1960341]  JavaThread::run()+0x191
V  [libjvm.so+0x164491a]  thread_native_entry(Thread*)+0xfa

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.Class.getLocalValueTypes0()[Ljava/lang/String;+0 java.base
j  java.lang.Class.getDeclaredValueTypeNames()Ljava/util/Set;+10 java.base
j  java.lang.System$2.getDeclaredValueTypeNames(Ljava/lang/Class;)Ljava/util/Set;+1 java.base
j  java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass()Ljava/lang/Class;+439 java.base
j  java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite()Ljava/lang/invoke/CallSite;+1 java.base
j  java.lang.invoke.LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;+31 java.base
j  java.lang.invoke.LambdaForm$DMH.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;+20 java.base
j  java.lang.invoke.LambdaForm$MH.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;+28 java.base
j  java.lang.invoke.BootstrapMethodInvoker.invoke(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+262 java.base
j  java.lang.invoke.CallSite.makeSite(Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/invoke/CallSite;+8 java.base
j  java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+6 java.base
j  java.lang.invoke.MethodHandleNatives.linkCallSite(Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+46 java.base
v  ~StubRoutines::call_stub
j  compiler.valhalla.valuetypes.TestLWorld.<clinit>()V+48
v  ~StubRoutines::call_stub
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 java.base
j  jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 java.base
j  jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6 java.base
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+59 java.base
j  com.sun.javatest.regtest.agent.MainWrapper$MainThread.run()V+172
j  java.lang.Thread.run()V+11 java.base
v  ~StubRoutines::call_stub

Comments
http://hg.openjdk.java.net/valhalla/valhalla/rev/eab3b58c9dde
17-07-2018

[~hseigel] thanks for the investigation and suggestion. mach5 job didn't catch this failure. Might be multiple tests running in the same agent VM that causes the value types resolved.
17-07-2018

The VM's value_types array is an array of these objects: class ValueTypes { public: u2 _class_info_index; Symbol* _class_name; }; But when ClassFileParser::parse_value_types_attribute() creates ValueTypes objects, it only initializes the _class_info_index. It sets _class_name to NULL. _class_name does not get set to a non-null Symbol* value until InstanceKlass::is_declared_value_type() is called by a function such as InstanceKlass::link_class_or_fail(). So if JVM_GetLocalValueTypes() got called before a class was linked then the ValueTypes _class_name field is likely to be NULL. One possible fix might be for JVM_GetLocalValueTypes() to do something similar to what InstanceKlass::is_declared_value_type() does when it finds that class name symbol has not been updated yet: bool InstanceKlass::is_declared_value_type(ConstantPool* constants, Array<ValueTypes>* value_types, Symbol* symbol) { assert(symbol != NULL, "Sanity check"); if (value_types == NULL) return false; // No ValueType attribute in this class file for(int i = 0; i < value_types->length(); i++) { if (value_types->at(i)._class_name == symbol) { return true; } } // symbol not found, class name symbol might not have been // updated yet for(int i = 0; i < value_types->length(); i++) { if (constants->klass_at_noresolve((int)value_types->at(i)._class_info_index) == symbol) { value_types->adr_at(i)->_class_name = symbol; symbol->increment_refcount(); return true; } } return false; }
17-07-2018

It looks like 'Symbol* vt' is getting set to NULL sometimes causing create_from_symbol() to crash: JVM_ENTRY(jobjectArray, JVM_GetLocalValueTypes(JNIEnv* env, jclass cls)) { JVMWrapper("JVM_GetLocalValueTypes"); Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); assert(k->is_instance_klass(), "must be"); InstanceKlass* ik = InstanceKlass::cast(k); if (ik->has_value_types_attribute()) { Array<ValueTypes>* value_types = ik->value_types(); int length = value_types->length(); objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), length, CHECK_NULL); objArrayHandle result(THREAD, r); for (int i=0; i < length; i++) { Symbol* vt = value_types->at(i)._class_name; if (vt == NULL) { ResourceMark rm; printf("JVM_GetLocalValueTypes, i: %d, length: %d, ik: %s\n", i, length, ik->name()->as_C_string()); } Handle s = java_lang_String::create_from_symbol(vt, CHECK_0); result->obj_at_put(i, s()); } return (jobjectArray)JNIHandles::make_local(THREAD, result()); } else { return NULL; } } JVM_END
17-07-2018

This was most likely introduced by JDK-8207194. Mandy, can you please have a look?
17-07-2018