RFR: 8304674: File java.c compile error with -fsanitize=address -O0

David Holmes dholmes at openjdk.org
Tue Nov 26 02:15:38 UTC 2024


On Mon, 25 Nov 2024 06:17:23 GMT, SendaoYan <syan at openjdk.org> wrote:

> Hi all,
> File `src/java.base/share/native/libjli/java.c` compile `error: control reaches end of non-void function [-Werror=return-type]` with gcc options `-fsanitize=address -O0`. The function `int JavaMain(void* _args)` in this file will execute `return ret` in `LEAVE()` macro, but gcc with -O0 is not smart enough to recognized that the function already has `return` statement before at the end of function.
> This PR add final return statement make gcc with options `-fsanitize=address -O0` happy, to make jdk compile success with configure option `--enable-asan` by slowdebug mode. The added `return ret` make no sence because the `LEAVE()` macro make sure that function will execute `returun ret` statement at java.c:348.  So I think this change is no risk.
> 
> Additional testing:
> 
> - [x]   jtreg tests(include tier1/2/3 etc.) with linux-x64 release build
> - [x]   jtreg tests(include tier1/2/3 etc.) with linux-x64 fastdebug build
> - [x]   jtreg tests(include tier1/2/3 etc.) with linux-aarch64 release build
> - [x]   jtreg tests(include tier1/2/3 etc.) with linux-aarch64 fastdebug build

Sorry but I don't agree with the change. This may appease the broken sanitizer logic, but may trigger an unreachable statement warning in a smarter compiler.

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

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22355#pullrequestreview-2460095290


More information about the core-libs-dev mailing list