Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8336256

memcpy short value to int local is incorrect in VtableStubs::unsafe_hash

XMLWordPrintable

    • 24
    • b07

      In VtableStubs::unsafe_hash()
      ```
      int vtable_index;
      memcpy(&vtable_index, vtable_index_addr, sizeof(vtable_index));
      ```
      the bytes are copied to the high part of vtable_index with big endian order because VtableStub::_index is a short (2 bytes) and vtable_index is an int (4 bytes).

      https://github.com/openjdk/jdk/blob/5c612c230b0a852aed5fd36e58b82ebf2e1838af/src/hotspot/share/code/vtableStubs.cpp#L266

      Also with little endian order this seems problematic because 2 bytes after _index are copied into vtable_index.

      On PPC64 BE we see crashes during the build.

      # assert(is_megamorphic()) failed: sanity check

      V [libjvm.so+0xd0aa20] CompiledIC::set_to_megamorphic(CallInfo*)+0x1d0 (compiledIC.cpp:261)
      V [libjvm.so+0x1a9cdc0] SharedRuntime::handle_ic_miss_helper(JavaThread*)+0x430 (sharedRuntime.cpp:1590)
      V [libjvm.so+0x1a9d1b4] SharedRuntime::handle_wrong_method_ic_miss(JavaThread*)+0x114 (sharedRuntime.cpp:1394)
      v ~RuntimeStub::ic_miss_stub 0x0000040002ead058
      J 57 c1 jdk.internal.classfile.impl.SplitConstantPool.internalAdd(Ljava/lang/classfile/constantpool/PoolEntry;)Ljava/lang/classfile/constantpool/PoolEntry; java.base (12 bytes) @ 0x0000040003178e10 [0x0000040003178d80+0x0000000000000090]
      j jdk.internal.classfile.impl.SplitConstantPool.classEntry(Ljava/lang/classfile/constantpool/Utf8Entry;)Ljdk/internal/classfile/impl/AbstractPoolEntry$ClassEntryImpl;+35 java.base
      j jdk.internal.classfile.impl.SplitConstantPool.classEntry(Ljava/lang/classfile/constantpool/Utf8Entry;)Ljava/lang/classfile/constantpool/ClassEntry;+2 java.base
      j java.lang.classfile.constantpool.ConstantPoolBuilder.classEntry(Ljava/lang/constant/ClassDesc;)Ljava/lang/classfile/constantpool/ClassEntry;+76 java.base
      j java.lang.classfile.ClassFile.build(Ljava/lang/constant/ClassDesc;Ljava/util/function/Consumer;)[B+7 java.base
      j java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass()Ljava/lang/Class;+171 java.base
      j java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass()Ljava/lang/Class;+120 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;+67 java.base
      j java.lang.invoke.LambdaForm$DMH+0x0000000085000400.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+0x0000000085001000.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;+319 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;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/invoke/MemberName;+45 java.base
      v ~StubRoutines::call_stub 0x0000040002da0860
      V [libjvm.so+0x121ab08] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x4e8 (javaCalls.cpp:415)
      V [libjvm.so+0x189b150] os::os_exception_wrapper(void (*)(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*), JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x40 (os_linux.cpp:4980)
      V [libjvm.so+0x121cb14] JavaCalls::call_static(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x1a4 (javaCalls.cpp:329)
      V [libjvm.so+0x1bb73f8] SystemDictionary::invoke_bootstrap_method(BootstrapInfo&, JavaThread*)+0x398 (systemDictionary.cpp:2348)
      V [libjvm.so+0x15c78f8] LinkResolver::resolve_dynamic_call(CallInfo&, BootstrapInfo&, JavaThread*)+0x48 (linkResolver.cpp:1893)
      V [libjvm.so+0x15c8068] LinkResolver::resolve_invokedynamic(CallInfo&, constantPoolHandle const&, int, JavaThread*)+0x268 (linkResolver.cpp:1865)
      V [libjvm.so+0x15d4290] LinkResolver::resolve_invoke(CallInfo&, Handle, constantPoolHandle const&, int, Bytecodes::Code, JavaThread*)+0x140 (linkResolver.cpp:1709)
      V [libjvm.so+0x11f38a8] InterpreterRuntime::resolve_invokedynamic(JavaThread*)+0x158 (interpreterRuntime.cpp:982)
      V [libjvm.so+0x11f7c88] InterpreterRuntime::resolve_from_cache(JavaThread*, Bytecodes::Code)+0x1b8 (interpreterRuntime.cpp:1010)
      j jdk.internal.module.ModulePath.readExplodedModule(Ljava/nio/file/Path;)Ljava/lang/module/ModuleReference;+30 java.base
      j jdk.internal.module.ModulePath.readModule(Ljava/nio/file/Path;Ljava/nio/file/attribute/BasicFileAttributes;)Ljava/lang/module/ModuleReference;+11 java.base
      j jdk.internal.module.ModulePath.scanDirectory(Ljava/nio/file/Path;)Ljava/util/Map;+69 java.base
      j jdk.internal.module.ModulePath.scan(Ljava/nio/file/Path;)Ljava/util/Map;+60 java.base
      j jdk.internal.module.ModulePath.scanNextEntry()V+23 java.base
      j jdk.internal.module.ModulePath.find(Ljava/lang/String;)Ljava/util/Optional;+36 java.base
      j jdk.internal.module.SystemModuleFinders$1.lambda$find$0(Ljava/lang/String;)Ljava/util/Optional;+5 java.base
      j jdk.internal.module.SystemModuleFinders$1$$Lambda+0x0000000085004b80.run()Ljava/lang/Object;+8 java.base
      j java.security.AccessController.executePrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/lang/Class;)Ljava/lang/Object;+29 java.base
      j java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;)Ljava/lang/Object;+5 java.base
      j jdk.internal.module.SystemModuleFinders$1.find(Ljava/lang/String;)Ljava/util/Optional;+9 java.base
      j jdk.internal.module.ModuleBootstrap.boot2()Ljava/lang/ModuleLayer;+298 java.base
      j jdk.internal.module.ModuleBootstrap.boot()Ljava/lang/ModuleLayer;+64 java.base
      j java.lang.System.initPhase2(ZZ)I+0 java.base
      v ~StubRoutines::call_stub 0x0000040002da0860
      V [libjvm.so+0x121ab08] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x4e8 (javaCalls.cpp:415)
      V [libjvm.so+0x189b150] os::os_exception_wrapper(void (*)(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*), JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x40 (os_linux.cpp:4980)
      V [libjvm.so+0x121cb14] JavaCalls::call_static(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x1a4 (javaCalls.cpp:329)
      V [libjvm.so+0x1c313b0] Threads::create_vm(JavaVMInitArgs*, bool*)+0x900 (threads.cpp:313)

            rrich Richard Reingruber
            rrich Richard Reingruber
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: