Bug Summary

File:jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp
Warning:line 73, column 10
Value stored to 'uncommitted' during its initialization is never read

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 freeChunkList.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/memory/metaspace/freeChunkList.cpp
1/*
2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2020 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26#include "precompiled.hpp"
27#include "memory/metaspace/freeChunkList.hpp"
28#include "utilities/debug.hpp"
29#include "utilities/globalDefinitions.hpp"
30#include "utilities/ostream.hpp"
31
32namespace metaspace {
33
34// Calculates total number of committed words over all chunks (walks chunks).
35size_t FreeChunkList::calc_committed_word_size() const {
36 size_t s = 0;
37 for (const Metachunk* c = _first; c != NULL__null; c = c->next()) {
38 s += c->committed_words();
39 }
40 return s;
41}
42
43void FreeChunkList::print_on(outputStream* st) const {
44 if (_num_chunks.get() > 0) {
45 for (const Metachunk* c = _first; c != NULL__null; c = c->next()) {
46 st->print(" - <");
47 c->print_on(st);
48 st->print(">");
49 }
50 st->print(" - total : %d chunks.", _num_chunks.get());
51 } else {
52 st->print("empty");
53 }
54}
55
56#ifdef ASSERT1
57
58bool FreeChunkList::contains(const Metachunk* c) const {
59 for (Metachunk* c2 = _first; c2 != NULL__null; c2 = c2->next()) {
60 if (c2 == c) {
61 return true;
62 }
63 }
64 return false;
65}
66
67void FreeChunkList::verify() const {
68 if (_first == NULL__null) {
69 assert(_last == NULL, "Sanity")do { if (!(_last == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 69, "assert(" "_last == __null" ") failed", "Sanity"); ::breakpoint
(); } } while (0)
;
70 } else {
71 assert(_last != NULL, "Sanity")do { if (!(_last != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 71, "assert(" "_last != __null" ") failed", "Sanity"); ::breakpoint
(); } } while (0)
;
72 int num = 0;
73 bool uncommitted = (_first->committed_words() == 0);
Value stored to 'uncommitted' during its initialization is never read
74 for (Metachunk* c = _first; c != NULL__null; c = c->next()) {
75 assert(c->is_free(), "Chunks in freelist should be free")do { if (!(c->is_free())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 75, "assert(" "c->is_free()" ") failed", "Chunks in freelist should be free"
); ::breakpoint(); } } while (0)
;
76 assert(c->used_words() == 0, "Chunk in freelist should have not used words.")do { if (!(c->used_words() == 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 76, "assert(" "c->used_words() == 0" ") failed", "Chunk in freelist should have not used words."
); ::breakpoint(); } } while (0)
;
77 assert(c->level() == _first->level(), "wrong level")do { if (!(c->level() == _first->level())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 77, "assert(" "c->level() == _first->level()" ") failed"
, "wrong level"); ::breakpoint(); } } while (0)
;
78 assert(c->next() == NULL || c->next()->prev() == c, "front link broken")do { if (!(c->next() == __null || c->next()->prev() ==
c)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 78, "assert(" "c->next() == __null || c->next()->prev() == c"
") failed", "front link broken"); ::breakpoint(); } } while (
0)
;
79 assert(c->prev() == NULL || c->prev()->next() == c, "back link broken")do { if (!(c->prev() == __null || c->prev()->next() ==
c)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 79, "assert(" "c->prev() == __null || c->prev()->next() == c"
") failed", "back link broken"); ::breakpoint(); } } while (
0)
;
80 assert(c != c->prev() && c != c->next(), "circle")do { if (!(c != c->prev() && c != c->next())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 80, "assert(" "c != c->prev() && c != c->next()"
") failed", "circle"); ::breakpoint(); } } while (0)
;
81 c->verify();
82 num++;
83 }
84 _num_chunks.check(num);
85 }
86}
87
88#endif // ASSERT
89
90// Returns total size in all lists (regardless of commit state of underlying memory)
91size_t FreeChunkListVector::word_size() const {
92 size_t sum = 0;
93 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
94 sum += list_for_level(l)->num_chunks() * chunklevel::word_size_for_level(l);
95 }
96 return sum;
97}
98
99// Calculates total number of committed words over all chunks (walks chunks).
100size_t FreeChunkListVector::calc_committed_word_size() const {
101 size_t sum = 0;
102 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
103 sum += calc_committed_word_size_at_level(l);
104 }
105 return sum;
106}
107
108size_t FreeChunkListVector::calc_committed_word_size_at_level(chunklevel_t lvl) const {
109 return list_for_level(lvl)->calc_committed_word_size();
110}
111
112// Returns total committed size in all lists
113int FreeChunkListVector::num_chunks() const {
114 int n = 0;
115 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
116 n += list_for_level(l)->num_chunks();
117 }
118 return n;
119}
120
121// Look for a chunk: starting at level, up to and including max_level,
122// return the first chunk whose committed words >= min_committed_words.
123// Return NULL if no such chunk was found.
124Metachunk* FreeChunkListVector::search_chunk_ascending(chunklevel_t level, chunklevel_t max_level, size_t min_committed_words) {
125 assert(min_committed_words <= chunklevel::word_size_for_level(max_level),do { if (!(min_committed_words <= chunklevel::word_size_for_level
(max_level))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 126, "assert(" "min_committed_words <= chunklevel::word_size_for_level(max_level)"
") failed", "min chunk size too small to hold min_committed_words"
); ::breakpoint(); } } while (0)
126 "min chunk size too small to hold min_committed_words")do { if (!(min_committed_words <= chunklevel::word_size_for_level
(max_level))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/memory/metaspace/freeChunkList.cpp"
, 126, "assert(" "min_committed_words <= chunklevel::word_size_for_level(max_level)"
") failed", "min chunk size too small to hold min_committed_words"
); ::breakpoint(); } } while (0)
;
127 for (chunklevel_t l = level; l <= max_level; l++) {
128 FreeChunkList* list = list_for_level(l);
129 Metachunk* c = list->first_minimally_committed(min_committed_words);
130 if (c != NULL__null) {
131 list->remove(c);
132 return c;
133 }
134 }
135 return NULL__null;
136}
137
138// Look for a chunk: starting at level, down to (including) the root chunk level,
139// return the first chunk whose committed words >= min_committed_words.
140// Return NULL if no such chunk was found.
141Metachunk* FreeChunkListVector::search_chunk_descending(chunklevel_t level, size_t min_committed_words) {
142 for (chunklevel_t l = level; l >= chunklevel::LOWEST_CHUNK_LEVEL; l --) {
143 FreeChunkList* list = list_for_level(l);
144 Metachunk* c = list->first_minimally_committed(min_committed_words);
145 if (c != NULL__null) {
146 list->remove(c);
147 return c;
148 }
149 }
150 return NULL__null;
151}
152
153void FreeChunkListVector::print_on(outputStream* st) const {
154 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
155 st->print("-- List[" CHKLVL_FORMAT"lv%.2d" "]: ", l);
156 list_for_level(l)->print_on(st);
157 st->cr();
158 }
159 st->print_cr("total chunks: %d, total word size: " SIZE_FORMAT"%" "l" "u" ".",
160 num_chunks(), word_size());
161}
162
163#ifdef ASSERT1
164
165void FreeChunkListVector::verify() const {
166 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
167 list_for_level(l)->verify();
168 }
169}
170
171bool FreeChunkListVector::contains(const Metachunk* c) const {
172 for (chunklevel_t l = chunklevel::LOWEST_CHUNK_LEVEL; l <= chunklevel::HIGHEST_CHUNK_LEVEL; l++) {
173 if (list_for_level(l)->contains(c)) {
174 return true;
175 }
176 }
177 return false;
178}
179
180#endif // ASSERT
181
182} // namespace metaspace
183