Bug Summary

File:jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp
Warning:line 63, column 31
Value stored to 'byte_arr_klass' 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 jfrMetadataEvent.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/jfrMetadataEvent.cpp
1/*
2 * Copyright (c) 2016, 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 "jfr/jni/jfrJavaSupport.hpp"
27#include "jfr/jni/jfrUpcalls.hpp"
28#include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp"
29#include "jfr/recorder/repository/jfrChunkWriter.hpp"
30#include "jfr/recorder/jfrEventSetting.inline.hpp"
31#include "oops/klass.inline.hpp"
32#include "oops/oop.inline.hpp"
33#include "oops/typeArrayOop.inline.hpp"
34#include "runtime/interfaceSupport.inline.hpp"
35#include "runtime/thread.inline.hpp"
36#include "utilities/exceptions.hpp"
37
38static jbyteArray metadata_blob = NULL__null;
39static u8 metadata_id = 0;
40static u8 last_metadata_id = 0;
41
42static void check_internal_types() {
43 static bool visible = false;
44 if (!visible && JfrEventSetting::is_internal_types_visible()) {
45 JavaThread* const jt = JavaThread::current();
46 DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(jt))JfrJavaSupport::check_java_thread_in_native(jt);
47 // can safepoint here
48 ThreadInVMfromNative transition(jt);
49 visible = JfrUpcalls::unhide_internal_types(jt);
50 }
51}
52
53static void write_metadata_blob(JfrChunkWriter& chunkwriter, JavaThread* thread) {
54 assert(chunkwriter.is_valid(), "invariant")do { if (!(chunkwriter.is_valid())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 54, "assert(" "chunkwriter.is_valid()" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
55 assert(thread != NULL, "invariant")do { if (!(thread != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 55, "assert(" "thread != __null" ") failed", "invariant"); ::
breakpoint(); } } while (0)
;
56 assert(metadata_blob != NULL, "invariant")do { if (!(metadata_blob != __null)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 56, "assert(" "metadata_blob != __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
57 DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread))JfrJavaSupport::check_java_thread_in_vm(thread);
58 const typeArrayOop arr = (typeArrayOop)JfrJavaSupport::resolve_non_null(metadata_blob);
59 assert(arr != NULL, "invariant")do { if (!(arr != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 59, "assert(" "arr != __null" ") failed", "invariant"); ::breakpoint
(); } } while (0)
;
60 const int length = arr->length();
61 const Klass* const k = arr->klass();
62 assert(k != NULL && k->is_array_klass(), "invariant")do { if (!(k != __null && k->is_array_klass())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 62, "assert(" "k != __null && k->is_array_klass()"
") failed", "invariant"); ::breakpoint(); } } while (0)
;
63 const TypeArrayKlass* const byte_arr_klass = TypeArrayKlass::cast(k);
Value stored to 'byte_arr_klass' during its initialization is never read
64 const jbyte* const data_address = arr->byte_at_addr(0);
65 chunkwriter.write_unbuffered(data_address, length);
66}
67
68void JfrMetadataEvent::write(JfrChunkWriter& chunkwriter) {
69 assert(chunkwriter.is_valid(), "invariant")do { if (!(chunkwriter.is_valid())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 69, "assert(" "chunkwriter.is_valid()" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
70 check_internal_types();
71 if (last_metadata_id == metadata_id && chunkwriter.has_metadata()) {
72 return;
73 }
74 JavaThread* const jt = JavaThread::current();
75 DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(jt))JfrJavaSupport::check_java_thread_in_native(jt);
76 // can safepoint here
77 ThreadInVMfromNative transition(jt);
78 // header
79 const int64_t metadata_offset = chunkwriter.reserve(sizeof(u4));
80 chunkwriter.write<u8>(EVENT_METADATA); // ID 0
81 // time data
82 chunkwriter.write(JfrTicks::now());
83 chunkwriter.write((u8)0); // duration
84 chunkwriter.write(metadata_id); // metadata id
85 write_metadata_blob(chunkwriter, jt); // payload
86 // fill in size of metadata descriptor event
87 const int64_t size_written = chunkwriter.current_offset() - metadata_offset;
88 chunkwriter.write_padded_at_offset((u4)size_written, metadata_offset);
89 chunkwriter.set_last_metadata_offset(metadata_offset);
90 last_metadata_id = metadata_id;
91}
92
93void JfrMetadataEvent::update(jbyteArray metadata) {
94 JavaThread* thread = JavaThread::current();
95 DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread))JfrJavaSupport::check_java_thread_in_vm(thread);
96 if (metadata_blob != NULL__null) {
97 JfrJavaSupport::destroy_global_jni_handle(metadata_blob);
98 }
99 const oop new_desc_oop = JfrJavaSupport::resolve_non_null(metadata);
100 assert(new_desc_oop != NULL, "invariant")do { if (!(new_desc_oop != __null)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp"
, 100, "assert(" "new_desc_oop != __null" ") failed", "invariant"
); ::breakpoint(); } } while (0)
;
101 metadata_blob = (jbyteArray)JfrJavaSupport::global_jni_handle(new_desc_oop, thread);
102 ++metadata_id;
103}