Bug Summary

File:jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp
Warning:line 319, column 10
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 jfrThreadGroup.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/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp
1/*
2 * Copyright (c) 2016, 2019, 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 "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp"
27#include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp"
28#include "jfr/utilities/jfrTypes.hpp"
29#include "runtime/handles.inline.hpp"
30#include "runtime/jniHandles.inline.hpp"
31#include "runtime/safepoint.hpp"
32#include "runtime/semaphore.hpp"
33#include "utilities/growableArray.hpp"
34
35static const int initial_array_size = 30;
36
37class ThreadGroupExclusiveAccess : public StackObj {
38 private:
39 static Semaphore _mutex_semaphore;
40 public:
41 ThreadGroupExclusiveAccess() { _mutex_semaphore.wait(); }
42 ~ThreadGroupExclusiveAccess() { _mutex_semaphore.signal(); }
43};
44
45Semaphore ThreadGroupExclusiveAccess::_mutex_semaphore(1);
46JfrThreadGroup* JfrThreadGroup::_instance = NULL__null;
47
48class JfrThreadGroupPointers : public ResourceObj {
49 private:
50 const Handle _thread_group_handle;
51 jweak _thread_group_weak_ref;
52 public:
53 JfrThreadGroupPointers(Handle thread_group_handle, jweak thread_group_weak_ref);
54 Handle thread_group_handle() const;
55 jweak thread_group_weak_ref() const;
56 oopDesc* const thread_group_oop() const;
57 jweak transfer_weak_global_handle_ownership();
58 void clear_weak_ref();
59};
60
61JfrThreadGroupPointers::JfrThreadGroupPointers(Handle thread_group_handle, jweak thread_group_weak_ref) :
62 _thread_group_handle(thread_group_handle),
63 _thread_group_weak_ref(thread_group_weak_ref) {}
64
65Handle JfrThreadGroupPointers::thread_group_handle() const {
66 return _thread_group_handle;
67}
68
69jweak JfrThreadGroupPointers::thread_group_weak_ref() const {
70 return _thread_group_weak_ref;
71}
72
73oopDesc* const JfrThreadGroupPointers::thread_group_oop() const {
74 assert(_thread_group_weak_ref == NULL ||do { if (!(_thread_group_weak_ref == __null || JNIHandles::resolve_non_null
(_thread_group_weak_ref) == _thread_group_handle())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 75, "assert(" "_thread_group_weak_ref == __null || JNIHandles::resolve_non_null(_thread_group_weak_ref) == _thread_group_handle()"
") failed", "invariant"); ::breakpoint(); } } while (0)
75 JNIHandles::resolve_non_null(_thread_group_weak_ref) == _thread_group_handle(), "invariant")do { if (!(_thread_group_weak_ref == __null || JNIHandles::resolve_non_null
(_thread_group_weak_ref) == _thread_group_handle())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 75, "assert(" "_thread_group_weak_ref == __null || JNIHandles::resolve_non_null(_thread_group_weak_ref) == _thread_group_handle()"
") failed", "invariant"); ::breakpoint(); } } while (0)
;
76 return _thread_group_handle();
77}
78
79jweak JfrThreadGroupPointers::transfer_weak_global_handle_ownership() {
80 jweak temp = _thread_group_weak_ref;
81 _thread_group_weak_ref = NULL__null;
82 return temp;
83}
84
85void JfrThreadGroupPointers::clear_weak_ref() {
86 if (NULL__null != _thread_group_weak_ref) {
87 JNIHandles::destroy_weak_global(_thread_group_weak_ref);
88 }
89}
90
91class JfrThreadGroupsHelper : public ResourceObj {
92 private:
93 static const int invalid_iterator_pos = -1;
94 GrowableArray<JfrThreadGroupPointers*>* _thread_group_hierarchy;
95 int _current_iterator_pos;
96
97 int populate_thread_group_hierarchy(const JavaThread* jt, Thread* current);
98 JfrThreadGroupPointers& at(int index);
99
100 public:
101 JfrThreadGroupsHelper(const JavaThread* jt, Thread* current);
102 ~JfrThreadGroupsHelper();
103 JfrThreadGroupPointers& next();
104 bool is_valid() const;
105 bool has_next() const;
106};
107
108JfrThreadGroupsHelper::JfrThreadGroupsHelper(const JavaThread* jt, Thread* current) {
109 _thread_group_hierarchy = new GrowableArray<JfrThreadGroupPointers*>(10);
110 _current_iterator_pos = populate_thread_group_hierarchy(jt, current) - 1;
111}
112
113JfrThreadGroupsHelper::~JfrThreadGroupsHelper() {
114 assert(_current_iterator_pos == invalid_iterator_pos, "invariant")do { if (!(_current_iterator_pos == invalid_iterator_pos)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 114, "assert(" "_current_iterator_pos == invalid_iterator_pos"
") failed", "invariant"); ::breakpoint(); } } while (0)
;
115 for (int i = 0; i < _thread_group_hierarchy->length(); ++i) {
116 _thread_group_hierarchy->at(i)->clear_weak_ref();
117 }
118}
119
120JfrThreadGroupPointers& JfrThreadGroupsHelper::at(int index) {
121 assert(_thread_group_hierarchy != NULL, "invariant")do { if (!(_thread_group_hierarchy != __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 121, "assert(" "_thread_group_hierarchy != __null" ") failed"
, "invariant"); ::breakpoint(); } } while (0)
;
122 assert(index > invalid_iterator_pos && index < _thread_group_hierarchy->length(), "invariant")do { if (!(index > invalid_iterator_pos && index <
_thread_group_hierarchy->length())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 122, "assert(" "index > invalid_iterator_pos && index < _thread_group_hierarchy->length()"
") failed", "invariant"); ::breakpoint(); } } while (0)
;
123 return *(_thread_group_hierarchy->at(index));
124}
125
126bool JfrThreadGroupsHelper::has_next() const {
127 return _current_iterator_pos > invalid_iterator_pos;
8
Returning zero, which participates in a condition later
128}
129
130bool JfrThreadGroupsHelper::is_valid() const {
131 return (_thread_group_hierarchy != NULL__null && _thread_group_hierarchy->length() > 0);
132}
133
134JfrThreadGroupPointers& JfrThreadGroupsHelper::next() {
135 assert(is_valid(), "invariant")do { if (!(is_valid())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 135, "assert(" "is_valid()" ") failed", "invariant"); ::breakpoint
(); } } while (0)
;
136 return at(_current_iterator_pos--);
137}
138
139/*
140 * If not at a safepoint, we create global weak references for
141 * all reachable threadgroups for this thread.
142 * If we are at a safepoint, the caller is the VMThread during
143 * JFR checkpointing. It can use naked oops, because nothing
144 * will move before the list of threadgroups is cleared and
145 * mutator threads restarted. The threadgroup list is cleared
146 * later by the VMThread as one of the final steps in JFR checkpointing
147 * (not here).
148 */
149int JfrThreadGroupsHelper::populate_thread_group_hierarchy(const JavaThread* jt, Thread* current) {
150 assert(jt != NULL && jt->is_Java_thread(), "invariant")do { if (!(jt != __null && jt->is_Java_thread())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 150, "assert(" "jt != __null && jt->is_Java_thread()"
") failed", "invariant"); ::breakpoint(); } } while (0)
;
151 assert(current != NULL, "invariant")do { if (!(current != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 151, "assert(" "current != __null" ") failed", "invariant")
; ::breakpoint(); } } while (0)
;
152 assert(_thread_group_hierarchy != NULL, "invariant")do { if (!(_thread_group_hierarchy != __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 152, "assert(" "_thread_group_hierarchy != __null" ") failed"
, "invariant"); ::breakpoint(); } } while (0)
;
153
154 oop thread_oop = jt->threadObj();
155 if (thread_oop == nullptr) {
156 return 0;
157 }
158 // immediate thread group
159 Handle thread_group_handle(current, java_lang_Thread::threadGroup(thread_oop));
160 if (thread_group_handle == NULL__null) {
161 return 0;
162 }
163
164 const bool use_weak_handles = !SafepointSynchronize::is_at_safepoint();
165 jweak thread_group_weak_ref = use_weak_handles ? JNIHandles::make_weak_global(thread_group_handle) : NULL__null;
166
167 JfrThreadGroupPointers* thread_group_pointers = new JfrThreadGroupPointers(thread_group_handle, thread_group_weak_ref);
168 _thread_group_hierarchy->append(thread_group_pointers);
169 // immediate parent thread group
170 oop parent_thread_group_obj = java_lang_ThreadGroup::parent(thread_group_handle());
171 Handle parent_thread_group_handle(current, parent_thread_group_obj);
172
173 // and check parents parents...
174 while (parent_thread_group_handle != nullptr) {
175 const jweak parent_group_weak_ref = use_weak_handles ? JNIHandles::make_weak_global(parent_thread_group_handle) : NULL__null;
176 thread_group_pointers = new JfrThreadGroupPointers(parent_thread_group_handle, parent_group_weak_ref);
177 _thread_group_hierarchy->append(thread_group_pointers);
178 parent_thread_group_obj = java_lang_ThreadGroup::parent(parent_thread_group_handle());
179 parent_thread_group_handle = Handle(current, parent_thread_group_obj);
180 }
181 return _thread_group_hierarchy->length();
182}
183
184static traceid next_id() {
185 static traceid _current_threadgroup_id = 0;
186 return ++_current_threadgroup_id;
187}
188
189class JfrThreadGroup::JfrThreadGroupEntry : public JfrCHeapObj {
190 friend class JfrThreadGroup;
191 private:
192 traceid _thread_group_id;
193 traceid _parent_group_id;
194 char* _thread_group_name; // utf8 format
195 // If an entry is created during a safepoint, the
196 // _thread_group_oop contains a direct oop to
197 // the java.lang.ThreadGroup object.
198 // If an entry is created on javathread exit time (not at safepoint),
199 // _thread_group_weak_ref contains a JNI weak global handle
200 // indirection to the java.lang.ThreadGroup object.
201 // Note: we cannot use a union here since CHECK_UNHANDLED_OOPS makes oop have
202 // a ctor which isn't allowed in a union by the SunStudio compiler
203 oop _thread_group_oop;
204 jweak _thread_group_weak_ref;
205
206 JfrThreadGroupEntry(const char* tgstr, JfrThreadGroupPointers& ptrs);
207 ~JfrThreadGroupEntry();
208
209 traceid thread_group_id() const { return _thread_group_id; }
210 void set_thread_group_id(traceid tgid) { _thread_group_id = tgid; }
211
212 const char* const thread_group_name() const { return _thread_group_name; }
213 void set_thread_group_name(const char* tgname);
214
215 traceid parent_group_id() const { return _parent_group_id; }
216 void set_parent_group_id(traceid pgid) { _parent_group_id = pgid; }
217
218 void set_thread_group(JfrThreadGroupPointers& ptrs);
219 bool is_equal(const JfrThreadGroupPointers& ptrs) const;
220 const oop thread_group() const;
221};
222
223JfrThreadGroup::JfrThreadGroupEntry::JfrThreadGroupEntry(const char* tgname, JfrThreadGroupPointers& ptrs) :
224 _thread_group_id(0),
225 _parent_group_id(0),
226 _thread_group_name(NULL__null),
227 _thread_group_oop(NULL__null),
228 _thread_group_weak_ref(NULL__null) {
229 set_thread_group_name(tgname);
230 set_thread_group(ptrs);
231}
232
233JfrThreadGroup::JfrThreadGroupEntry::~JfrThreadGroupEntry() {
234 if (_thread_group_name != NULL__null) {
235 JfrCHeapObj::free(_thread_group_name, strlen(_thread_group_name) + 1);
236 }
237 if (_thread_group_weak_ref != NULL__null) {
238 JNIHandles::destroy_weak_global(_thread_group_weak_ref);
239 }
240}
241
242void JfrThreadGroup::JfrThreadGroupEntry::set_thread_group_name(const char* tgname) {
243 assert(_thread_group_name == NULL, "invariant")do { if (!(_thread_group_name == __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 243, "assert(" "_thread_group_name == __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
244 if (tgname != NULL__null) {
245 size_t len = strlen(tgname);
246 _thread_group_name = JfrCHeapObj::new_array<char>(len + 1);
247 strncpy(_thread_group_name, tgname, len + 1);
248 }
249}
250
251const oop JfrThreadGroup::JfrThreadGroupEntry::thread_group() const {
252 return _thread_group_weak_ref != NULL__null ? JNIHandles::resolve(_thread_group_weak_ref) : _thread_group_oop;
253}
254
255void JfrThreadGroup::JfrThreadGroupEntry::set_thread_group(JfrThreadGroupPointers& ptrs) {
256 _thread_group_weak_ref = ptrs.transfer_weak_global_handle_ownership();
257 if (_thread_group_weak_ref == NULL__null) {
258 _thread_group_oop = ptrs.thread_group_oop();
259 assert(_thread_group_oop != NULL, "invariant")do { if (!(_thread_group_oop != __null)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 259, "assert(" "_thread_group_oop != __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
260 } else {
261 _thread_group_oop = NULL__null;
262 }
263}
264
265JfrThreadGroup::JfrThreadGroup() :
266 _list(new (ResourceObj::C_HEAP, mtTracing) GrowableArray<JfrThreadGroupEntry*>(initial_array_size, mtTracing)) {}
267
268JfrThreadGroup::~JfrThreadGroup() {
269 if (_list != NULL__null) {
270 for (int i = 0; i < _list->length(); i++) {
271 JfrThreadGroupEntry* e = _list->at(i);
272 delete e;
273 }
274 delete _list;
275 }
276}
277
278JfrThreadGroup* JfrThreadGroup::instance() {
279 return _instance;
280}
281
282void JfrThreadGroup::set_instance(JfrThreadGroup* new_instance) {
283 _instance = new_instance;
284}
285
286traceid JfrThreadGroup::thread_group_id(const JavaThread* jt, Thread* current) {
287 JfrThreadGroupsHelper helper(jt, current);
288 return helper.is_valid() ? thread_group_id_internal(helper) : 0;
2
'?' condition is true
3
Calling 'JfrThreadGroup::thread_group_id_internal'
289}
290
291traceid JfrThreadGroup::thread_group_id(JavaThread* const jt) {
292 return thread_group_id(jt, jt);
1
Calling 'JfrThreadGroup::thread_group_id'
293}
294
295traceid JfrThreadGroup::thread_group_id_internal(JfrThreadGroupsHelper& helper) {
296 ThreadGroupExclusiveAccess lock;
297 JfrThreadGroup* tg_instance = instance();
298 if (tg_instance == NULL__null) {
4
Assuming 'tg_instance' is not equal to NULL
5
Taking false branch
299 tg_instance = new JfrThreadGroup();
300 if (tg_instance == NULL__null) {
301 return 0;
302 }
303 set_instance(tg_instance);
304 }
305
306 JfrThreadGroupEntry* tge = NULL__null;
6
'tge' initialized to a null pointer value
307 int parent_thread_group_id = 0;
308 while (helper.has_next()) {
7
Calling 'JfrThreadGroupsHelper::has_next'
9
Returning from 'JfrThreadGroupsHelper::has_next'
10
Loop condition is false. Execution continues on line 319
309 JfrThreadGroupPointers& ptrs = helper.next();
310 tge = tg_instance->find_entry(ptrs);
311 if (NULL__null == tge) {
312 tge = tg_instance->new_entry(ptrs);
313 assert(tge != NULL, "invariant")do { if (!(tge != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 313, "assert(" "tge != __null" ") failed", "invariant"); ::
breakpoint(); } } while (0)
;
314 tge->set_parent_group_id(parent_thread_group_id);
315 }
316 parent_thread_group_id = tge->thread_group_id();
317 }
318 // the last entry in the hierarchy is the immediate thread group
319 return tge->thread_group_id();
11
Called C++ object pointer is null
320}
321
322bool JfrThreadGroup::JfrThreadGroupEntry::is_equal(const JfrThreadGroupPointers& ptrs) const {
323 return ptrs.thread_group_oop() == thread_group();
324}
325
326JfrThreadGroup::JfrThreadGroupEntry*
327JfrThreadGroup::find_entry(const JfrThreadGroupPointers& ptrs) const {
328 for (int index = 0; index < _list->length(); ++index) {
329 JfrThreadGroupEntry* curtge = _list->at(index);
330 if (curtge->is_equal(ptrs)) {
331 return curtge;
332 }
333 }
334 return (JfrThreadGroupEntry*) NULL__null;
335}
336
337// Assumes you already searched for the existence
338// of a corresponding entry in find_entry().
339JfrThreadGroup::JfrThreadGroupEntry*
340JfrThreadGroup::new_entry(JfrThreadGroupPointers& ptrs) {
341 JfrThreadGroupEntry* const tge = new JfrThreadGroupEntry(java_lang_ThreadGroup::name(ptrs.thread_group_oop()), ptrs);
342 add_entry(tge);
343 return tge;
344}
345
346int JfrThreadGroup::add_entry(JfrThreadGroupEntry* tge) {
347 assert(tge != NULL, "attempting to add a null entry!")do { if (!(tge != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 347, "assert(" "tge != __null" ") failed", "attempting to add a null entry!"
); ::breakpoint(); } } while (0)
;
348 assert(0 == tge->thread_group_id(), "id must be unassigned!")do { if (!(0 == tge->thread_group_id())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 348, "assert(" "0 == tge->thread_group_id()" ") failed",
"id must be unassigned!"); ::breakpoint(); } } while (0)
;
349 tge->set_thread_group_id(next_id());
350 return _list->append(tge);
351}
352
353void JfrThreadGroup::write_thread_group_entries(JfrCheckpointWriter& writer) const {
354 assert(_list != NULL && !_list->is_empty(), "should not need be here!")do { if (!(_list != __null && !_list->is_empty()))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 354, "assert(" "_list != __null && !_list->is_empty()"
") failed", "should not need be here!"); ::breakpoint(); } }
while (0)
;
355 const int number_of_tg_entries = _list->length();
356 writer.write_count(number_of_tg_entries);
357 for (int index = 0; index < number_of_tg_entries; ++index) {
358 const JfrThreadGroupEntry* const curtge = _list->at(index);
359 writer.write_key(curtge->thread_group_id());
360 writer.write(curtge->parent_group_id());
361 writer.write(curtge->thread_group_name());
362 }
363}
364
365void JfrThreadGroup::write_selective_thread_group(JfrCheckpointWriter* writer, traceid thread_group_id) const {
366 assert(writer != NULL, "invariant")do { if (!(writer != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 366, "assert(" "writer != __null" ") failed", "invariant");
::breakpoint(); } } while (0)
;
367 assert(_list != NULL && !_list->is_empty(), "should not need be here!")do { if (!(_list != __null && !_list->is_empty()))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 367, "assert(" "_list != __null && !_list->is_empty()"
") failed", "should not need be here!"); ::breakpoint(); } }
while (0)
;
368 const int number_of_tg_entries = _list->length();
369
370 // save context
371 const JfrCheckpointContext ctx = writer->context();
372 writer->write_type(TYPE_THREADGROUP);
373 const jlong count_offset = writer->reserve(sizeof(u4)); // Don't know how many yet
374 int number_of_entries_written = 0;
375 for (int index = number_of_tg_entries - 1; index >= 0; --index) {
376 const JfrThreadGroupEntry* const curtge = _list->at(index);
377 if (thread_group_id == curtge->thread_group_id()) {
378 writer->write_key(curtge->thread_group_id());
379 writer->write(curtge->parent_group_id());
380 writer->write(curtge->thread_group_name());
381 ++number_of_entries_written;
382 thread_group_id = curtge->parent_group_id();
383 }
384 }
385 if (number_of_entries_written == 0) {
386 // nothing to write, restore context
387 writer->set_context(ctx);
388 return;
389 }
390 assert(number_of_entries_written > 0, "invariant")do { if (!(number_of_entries_written > 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 390, "assert(" "number_of_entries_written > 0" ") failed"
, "invariant"); ::breakpoint(); } } while (0)
;
391 writer->write_count(number_of_entries_written, count_offset);
392}
393
394// Write out JfrThreadGroup instance and then delete it
395void JfrThreadGroup::serialize(JfrCheckpointWriter& writer) {
396 ThreadGroupExclusiveAccess lock;
397 JfrThreadGroup* tg_instance = instance();
398 assert(tg_instance != NULL, "invariant")do { if (!(tg_instance != __null)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 398, "assert(" "tg_instance != __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
399 tg_instance->write_thread_group_entries(writer);
400}
401
402// for writing a particular thread group
403void JfrThreadGroup::serialize(JfrCheckpointWriter* writer, traceid thread_group_id) {
404 assert(writer != NULL, "invariant")do { if (!(writer != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 404, "assert(" "writer != __null" ") failed", "invariant");
::breakpoint(); } } while (0)
;
405 ThreadGroupExclusiveAccess lock;
406 JfrThreadGroup* const tg_instance = instance();
407 assert(tg_instance != NULL, "invariant")do { if (!(tg_instance != __null)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp"
, 407, "assert(" "tg_instance != __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
408 tg_instance->write_selective_thread_group(writer, thread_group_id);
409}