ASAN and slowdebug

David Holmes david.holmes at oracle.com
Tue Mar 21 01:03:18 UTC 2023


On 21/03/2023 3:45 am, Justin King wrote:
> Ew. So for `MemoryService::create_MemoryUsage_obj` it's effectively 
> adding stuff after the return statement, causing the compiler to 
> complain. I think for `MemoryService::create_MemoryUsage_obj` that last 
> CHECK should probably be changed to THREAD since it's not useful.

Yep. We have been cleaning these up as we discover them, but no easy way 
to find them.

David

  and the
> code added after the return is unreachable. And LEAVE should probably be 
> changed to not have the return statement wrapped in an arbitrary if 
> statement with JNI_TRUE as the expression, unless there is a reason for 
> that.
> 
> On Mon, Mar 20, 2023 at 10:34 AM Stuart Monteith 
> <stuart.monteith at arm.com <mailto:stuart.monteith at arm.com>> wrote:
> 
>     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
>     <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
> 
> 
> 
> -- 
> 
> Google Logo	
> Justin King
> Software Engineer
> jcking at google.com <mailto:jcking at google.com>
> 
> 	
> 


More information about the hotspot-dev mailing list