RFR: 8304674: File java.c compile error with -fsanitize=address -O0
Jaikiran Pai
jpai at openjdk.org
Mon Nov 25 07:15:13 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 missed last return statement, The original last macro statement `LEAVE();` in this fucntion do nothing since `do {...} while (JNI_FALSE)` is alway false and make no sense. This PR add final return statement make function complement, I think this change almost no risk.
>
> Additional testing:
>
> - [ ] jtreg tests(include tier1/2/3 etc.) with linux-x64 release build
> - [ ] jtreg tests(include tier1/2/3 etc.) with linux-x64 fastdebug build
> - [ ] jtreg tests(include tier1/2/3 etc.) with linux-aarch64 release build
> - [ ] jtreg tests(include tier1/2/3 etc.) with linux-aarch64 fastdebug build
Hello @sendaoYan,
> The original last macro statement LEAVE(); in this fucntion do nothing since do {...} while (JNI_FALSE) is alway false and make no sense. This PR add final return statement make function complement
My knowledge of C is very minimal so I'm not following what the issue is in the original macro which looks like:
#define LEAVE() \
do { \
if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
JLI_ReportErrorMessage(JVM_ERROR2); \
ret = 1; \
} \
if (JNI_TRUE) { \
(*vm)->DestroyJavaVM(vm); \
return ret; \
} \
} while (JNI_FALSE)
Do you mean that the `if (JNI_TRUE)` block which has the `return ret;` wouldn't be used by the preprocessor when using `-O0`?
Edit: I see David has a similar question as me.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22355#issuecomment-2497038354
More information about the core-libs-dev
mailing list