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

[ASAN] methodMatcher.cpp report reading from a region of size 0 [-Werror=stringop-overread]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 24
    • 11, 17, 21, 24
    • hotspot
    • b27
    • generic
    • linux

      File src/hotspot/share/compiler/methodMatcher.cpp report compile warning by gcc14 with -fsanitize=undefined -fsanitize=address, show as below:

      > g++ -MMD -MF build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/methodMatcher.d.tmp -fpch-preprocess -Ibuild/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 -pipe -fno-rtti -fno-exceptions -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer -fstack-protector -std=c++14 -DLIBC=gnu -DLINUX -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wformat=2 -Wpointer-arith -Wreturn-type -Wsign-compare -Wtrampolines -Wundef -Wunused-const-variable=1 -Wunused-function -Wunused-result -Wunused-value -Woverloaded-virtual -Wreorder -fPIC -DVM_LITTLE_ENDIAN -D_LP64=1 -fno-lifetime-dse -Wno-format-zero-length -Wtype-limits -Wuninitialized -m64 -fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER --param asan-use-after-return=0 -fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER -fsanitize=leak -fno-omit-frame-pointer -DLEAK_SANITIZER -DASSERT -DCHECK_UNHANDLED_OOPS -DTARGET_ARCH_x86 -DINCLUDE_SUFFIX_OS=_linux -DINCLUDE_SUFFIX_CPU=_x86 -DINCLUDE_SUFFIX_COMPILER=_gcc -DTARGET_COMPILER_gcc -DAMD64 '-DHOTSPOT_LIB_ARCH="amd64"' -DCOMPILER1 -DCOMPILER2 -DDTRACE_ENABLED -Ibuild/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -Isrc/hotspot/share -Isrc/hotspot/os/linux -Isrc/hotspot/os/posix -Isrc/hotspot/cpu/x86 -Isrc/hotspot/os_cpu/linux_x86 -Ibuild/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -Isrc/hotspot/share/precompiled -Isrc/hotspot/share/include -Isrc/hotspot/os/posix/include -Ibuild/linux-x86_64-server-fastdebug/support/modules_include/java.base -Ibuild/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -Isrc/java.base/share/native/libjimage -m64 -Ibuild/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -Isrc/hotspot/share -Isrc/hotspot/os/linux -Isrc/hotspot/os/posix -Isrc/hotspot/cpu/x86 -Isrc/hotspot/os_cpu/linux_x86 -Ibuild/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -Ibuild/linux-x86_64-server-fastdebug/support/modules_include/java.base -Isrc/java.base/unix/native/include -Isrc/java.base/share/native/include -g -gdwarf-4 -Wno-unused-parameter -Wno-array-bounds -Wno-comment -Wno-delete-non-virtual-dtor -Wno-empty-body -Wno-implicit-fallthrough -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Wno-unused-variable -Wno-strict-overflow -Werror -O3 -D_FORTIFY_SOURCE=2 -c -o build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/methodMatcher.o src/hotspot/share/compiler/methodMatcher.cpp -frandom-seed=methodMatcher.cpp -O3 -fsanitize=address
      src/hotspot/share/compiler/methodMatcher.cpp: In function ‘MethodMatcher::Mode check_mode(char*, const char*&)’:
      src/hotspot/share/compiler/methodMatcher.cpp:227:35: error: ‘size_t strlen(const char*)’ reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
        227 | memmove(name, name + 1, strlen(name + 1) + 1);
            | ~~~~~~^~~~~~~~~~
      cc1plus: note: source object is likely at address zero
      In file included from /usr/include/string.h:519,
                       from src/hotspot/share/utilities/globalDefinitions_gcc.hpp:37,
                       from src/hotspot/share/utilities/globalDefinitions.hpp:35,
                       from src/hotspot/share/nmt/memTag.hpp:28,
                       from src/hotspot/share/memory/allocation.hpp:29,
                       from src/hotspot/share/classfile/classLoaderData.hpp:28,
                       from src/hotspot/share/precompiled/precompiled.hpp:34:
      In function ‘void* memmove(void*, const void*, size_t)’,
          inlined from ‘MethodMatcher::Mode check_mode(char*, const char*&)’ at src/hotspot/share/compiler/methodMatcher.cpp:227:12:
      /usr/include/bits/string_fortified.h:35:34: error: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ reading between 1 and 9223372036854775806 bytes from a region of size 0 [-Werror=stringop-overread]
         35 | return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
            | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In function ‘MethodMatcher::Mode check_mode(char*, const char*&)’:
      cc1plus: note: source object is likely at address zero
      cc1plus: all warnings being treated as errors

            syan Sendao Yan
            syan Sendao Yan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: