ASAN and slowdebug

Justin King jcking at google.com
Mon Mar 20 17:45:40 UTC 2023


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 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>
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
>
> 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
>
>

-- 

[image: Google Logo]
Justin King
Software Engineer
jcking at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20230320/dea90f2c/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3999 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20230320/dea90f2c/smime-0001.p7s>


More information about the hotspot-dev mailing list