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

Kim Barrett kbarrett at openjdk.org
Wed Nov 27 15:37:44 UTC 2024


On Wed, 27 Nov 2024 15:20:24 GMT, SendaoYan <syan at openjdk.org> wrote:

>> Hi all,
>> The file src/hotspot/share/compiler/methodMatcher.cpp report compile warning by gcc14 with -fsanitize=undefined -fsanitize=address `‘size_t strlen(const char*)’ reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]`. I think it's false positive, the `if (name[0] == '*')` and `if (strlen(name) == 1)` judgement has make sure that the length of name greater or equal to 2, but the static analyze at compile time is unable to identify that.
>> So this PR change `strlen(name + 1) + 1` to `strlen(name)` to dodge gcc warning.  Risk is low.
>> 
>> Additional testing:
>> 
>> - [ ] jtreg tests(include tier1/2/3 etc.) by linux-x64 release build
>> - [ ] jtreg tests(include tier1/2/3 etc.) by linux-aarch64 release build
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   combine the calacution of stelen

Looks good.  Glad we don't need to uglify things with the warning suppression.

-------------

Marked as reviewed by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22406#pullrequestreview-2465377864


More information about the hotspot-dev mailing list