Bug Summary

File:jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp
Warning:line 54, column 5
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ciObjArrayKlass.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp
1/*
2 * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#include "precompiled.hpp"
26#include "ci/ciInstanceKlass.hpp"
27#include "ci/ciObjArrayKlass.hpp"
28#include "ci/ciSymbol.hpp"
29#include "ci/ciUtilities.inline.hpp"
30#include "oops/objArrayKlass.hpp"
31#include "runtime/signature.hpp"
32
33// ciObjArrayKlass
34//
35// This class represents a Klass* in the HotSpot virtual machine
36// whose Klass part is an ObjArrayKlass.
37
38// ------------------------------------------------------------------
39// ciObjArrayKlass::ciObjArrayKlass
40//
41// Constructor for loaded object array klasses.
42ciObjArrayKlass::ciObjArrayKlass(Klass* k) : ciArrayKlass(k) {
43 assert(get_Klass()->is_objArray_klass(), "wrong type")do { if (!(get_Klass()->is_objArray_klass())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 43, "assert(" "get_Klass()->is_objArray_klass()" ") failed"
, "wrong type"); ::breakpoint(); } } while (0)
;
1
Taking false branch
2
Loop condition is false. Exiting loop
44 Klass* element_Klass = get_ObjArrayKlass()->bottom_klass();
45 _base_element_klass = CURRENT_ENVciEnv::current()->get_klass(element_Klass);
46 assert(_base_element_klass->is_instance_klass() ||do { if (!(_base_element_klass->is_instance_klass() || _base_element_klass
->is_type_array_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 47, "assert(" "_base_element_klass->is_instance_klass() || _base_element_klass->is_type_array_klass()"
") failed", "bad base klass"); ::breakpoint(); } } while (0)
3
Assuming the condition is true
4
Taking false branch
5
Loop condition is false. Exiting loop
47 _base_element_klass->is_type_array_klass(), "bad base klass")do { if (!(_base_element_klass->is_instance_klass() || _base_element_klass
->is_type_array_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 47, "assert(" "_base_element_klass->is_instance_klass() || _base_element_klass->is_type_array_klass()"
") failed", "bad base klass"); ::breakpoint(); } } while (0)
;
48 if (dimension() == 1) {
6
Assuming the condition is false
7
Taking false branch
49 _element_klass = _base_element_klass;
50 } else {
51 _element_klass = NULL__null;
8
Null pointer value stored to field '_element_klass'
52 }
53 if (!ciObjectFactory::is_initialized()) {
9
Assuming the condition is true
10
Taking true branch
54 assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared")do { if (!(_element_klass->is_java_lang_Object())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 54, "assert(" "_element_klass->is_java_lang_Object()" ") failed"
, "only arrays of object are shared"); ::breakpoint(); } } while
(0)
;
11
Called C++ object pointer is null
55 }
56}
57
58// ------------------------------------------------------------------
59// ciObjArrayKlass::ciObjArrayKlass
60//
61// Constructor for unloaded object array klasses.
62ciObjArrayKlass::ciObjArrayKlass(ciSymbol* array_name,
63 ciKlass* base_element_klass,
64 int dimension)
65 : ciArrayKlass(array_name,
66 dimension, T_OBJECT) {
67 _base_element_klass = base_element_klass;
68 assert(_base_element_klass->is_instance_klass() ||do { if (!(_base_element_klass->is_instance_klass() || _base_element_klass
->is_type_array_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 69, "assert(" "_base_element_klass->is_instance_klass() || _base_element_klass->is_type_array_klass()"
") failed", "bad base klass"); ::breakpoint(); } } while (0)
69 _base_element_klass->is_type_array_klass(), "bad base klass")do { if (!(_base_element_klass->is_instance_klass() || _base_element_klass
->is_type_array_klass())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 69, "assert(" "_base_element_klass->is_instance_klass() || _base_element_klass->is_type_array_klass()"
") failed", "bad base klass"); ::breakpoint(); } } while (0)
;
70 if (dimension == 1) {
71 _element_klass = base_element_klass;
72 } else {
73 _element_klass = NULL__null;
74 }
75}
76
77// ------------------------------------------------------------------
78// ciObjArrayKlass::element_klass
79//
80// What is the one-level element type of this array?
81ciKlass* ciObjArrayKlass::element_klass() {
82 if (_element_klass == NULL__null) {
83 assert(dimension() > 1, "_element_klass should not be NULL")do { if (!(dimension() > 1)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/ci/ciObjArrayKlass.cpp"
, 83, "assert(" "dimension() > 1" ") failed", "_element_klass should not be NULL"
); ::breakpoint(); } } while (0)
;
84 // Produce the element klass.
85 if (is_loaded()) {
86 VM_ENTRY_MARKCompilerThread* thread=CompilerThread::current(); ThreadInVMfromNative
__tiv(thread); HandleMarkCleaner __hm(thread); JavaThread* __the_thread__
= thread; VMNativeEntryWrapper __vew;
;
87 Klass* element_Klass = get_ObjArrayKlass()->element_klass();
88 _element_klass = CURRENT_THREAD_ENVciEnv::current(thread)->get_klass(element_Klass);
89 } else {
90 VM_ENTRY_MARKCompilerThread* thread=CompilerThread::current(); ThreadInVMfromNative
__tiv(thread); HandleMarkCleaner __hm(thread); JavaThread* __the_thread__
= thread; VMNativeEntryWrapper __vew;
;
91 // We are an unloaded array klass. Attempt to fetch our
92 // element klass by name.
93 _element_klass = CURRENT_THREAD_ENVciEnv::current(thread)->get_klass_by_name_impl(
94 this,
95 constantPoolHandle(),
96 construct_array_name(base_element_klass()->name(),
97 dimension() - 1),
98 false);
99 }
100 }
101 return _element_klass;
102}
103
104// ------------------------------------------------------------------
105// ciObjArrayKlass::construct_array_name
106//
107// Build an array name from an element name and a dimension.
108ciSymbol* ciObjArrayKlass::construct_array_name(ciSymbol* element_name,
109 int dimension) {
110 EXCEPTION_CONTEXTCompilerThread* thread = CompilerThread::current(); JavaThread
* __the_thread__ = thread;
;
111 int element_len = element_name->utf8_length();
112 int buflen = dimension + element_len + 3; // '['+ + 'L'? + (element) + ';'? + '\0'
113 char* name = CURRENT_THREAD_ENVciEnv::current(thread)->name_buffer(buflen);
114 int pos = 0;
115 for ( ; pos < dimension; pos++) {
116 name[pos] = JVM_SIGNATURE_ARRAY;
117 }
118 Symbol* base_name_sym = element_name->get_symbol();
119
120 if (Signature::is_array(base_name_sym) ||
121 Signature::has_envelope(base_name_sym)) {
122 strncpy(&name[pos], (char*)element_name->base(), element_len);
123 name[pos + element_len] = '\0';
124 } else {
125 name[pos++] = JVM_SIGNATURE_CLASS;
126 strncpy(&name[pos], (char*)element_name->base(), element_len);
127 name[pos + element_len] = JVM_SIGNATURE_ENDCLASS;
128 name[pos + element_len + 1] = '\0';
129 }
130 return ciSymbol::make(name);
131}
132
133// ------------------------------------------------------------------
134// ciObjArrayKlass::make_impl
135//
136// Implementation of make.
137ciObjArrayKlass* ciObjArrayKlass::make_impl(ciKlass* element_klass) {
138
139 if (element_klass->is_loaded()) {
140 EXCEPTION_CONTEXTCompilerThread* thread = CompilerThread::current(); JavaThread
* __the_thread__ = thread;
;
141 // The element klass is loaded
142 Klass* array = element_klass->get_Klass()->array_klass(THREAD__the_thread__);
143 if (HAS_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->has_pending_exception())) {
144 CLEAR_PENDING_EXCEPTION(((ThreadShadow*)__the_thread__)->clear_pending_exception(
))
;
145 CURRENT_THREAD_ENVciEnv::current(thread)->record_out_of_memory_failure();
146 return ciEnv::unloaded_ciobjarrayklass();
147 }
148 return CURRENT_THREAD_ENVciEnv::current(thread)->get_obj_array_klass(array);
149 }
150
151 // The array klass was unable to be made or the element klass was
152 // not loaded.
153 ciSymbol* array_name = construct_array_name(element_klass->name(), 1);
154 if (array_name == ciEnv::unloaded_cisymbol()) {
155 return ciEnv::unloaded_ciobjarrayklass();
156 }
157 return
158 CURRENT_ENVciEnv::current()->get_unloaded_klass(element_klass, array_name)
159 ->as_obj_array_klass();
160}
161
162// ------------------------------------------------------------------
163// ciObjArrayKlass::make
164//
165// Make an array klass corresponding to the specified primitive type.
166ciObjArrayKlass* ciObjArrayKlass::make(ciKlass* element_klass) {
167 GUARDED_VM_ENTRY(return make_impl(element_klass);){if (ciEnv::is_in_vm()) { return make_impl(element_klass); } else
{ CompilerThread* thread=CompilerThread::current(); ThreadInVMfromNative
__tiv(thread); HandleMarkCleaner __hm(thread); JavaThread* __the_thread__
= thread; VMNativeEntryWrapper __vew;; { return make_impl(element_klass
); }}}
168}
169
170ciKlass* ciObjArrayKlass::exact_klass() {
171 ciType* base = base_element_type();
172 if (base->is_instance_klass()) {
173 ciInstanceKlass* ik = base->as_instance_klass();
174 if (ik->exact_klass() != NULL__null) {
175 return this;
176 }
177 } else if (base->is_primitive_type()) {
178 return this;
179 }
180 return NULL__null;
181}