ASAN and slowdebug
Stuart Monteith
stuart.monteith at arm.com
Mon Mar 20 17:32:50 UTC 2023
Hello,
While looking at ASAN to try to reproduce another issue with ASAN, I tried building OpenJDK configured with:
--enable-asan --with-debug-level=slowdebug
However, there is a compilation problem that persists up to and include GCC 12.2.0:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80959
As slowdebug builds are built with -O0, this results in code to be inserted by the macros LEAVE() and CHECK_NH+CHECK_
macros to be not optimised away. This causes the following two warnings/errors:
* For target hotspot_variant-server_libjvm_objs_memoryService.o:
jdk/src/hotspot/share/services/memoryService.cpp: In static member function 'static Handle
MemoryService::create_MemoryUsage_obj(MemoryUsage, JavaThread*)':
jdk/src/hotspot/share/services/memoryService.cpp:219:1: error: control reaches end of non-void function
[-Werror=return-type]
* For target support_native_java.base_libjli_java.o:
jdk/src/java.base/share/native/libjli/java.c: In function 'JavaMain':
jdk/src/java.base/share/native/libjli/java.c:556:1: error: control reaches end of non-void function [-Werror=return-type]
556 | }
| ^
There are a couple of ways of working around this. One is to change create_MemoryUsage_obj and libjli/java.c to place a
return statement at the end of the function block, after the macros. The changes are straightforward, but we're
obviously not guaranteed to not reintroduce the problem elsewhere.
Another is to pass: "--disable-warnings-as-errors" or more specifically "--with-extra-cflags=-Wno-return-type
--with-extra-cxxflags=-Wno-return-type" to configure. This would be a manual process, unless the make files were changed
to handle this, however this does remove the return type checks.
Part of the reason for sending this is to at least document the issue publicly. Are there any opinions on what should to
be done next?
Stuart
More information about the hotspot-dev
mailing list