RFR: 8338449: ubsan: division by zero in sharedRuntimeTrans.cpp

Dean Long dlong at openjdk.org
Tue Oct 22 19:30:05 UTC 2024


On Mon, 14 Oct 2024 14:08:05 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> When running with ubsan enabled binaries on Linux ppc64le, some divisions by zero are detected in the java/lang/Math jdk jtreg tests dealing with log - related calculations.
> 
> java/lang/Math/Log10Tests.java: Tests for {Math, StrictMath}.log10
>  
> /jdk/src/hotspot/share/runtime/sharedRuntimeTrans.cpp:219:27: runtime error: division by zero
>     #0 0x7fffa7e14abc in SharedRuntime::dlog10(double) (/build_ubsan/images/jdk/lib/server/libjvm.so+0x69f4abc)
>     #1 0x7fff8b8fc8e8 (<unknown module>)
>  
> test
> java/lang/Math/LogTests.java: Tests for {Math, StrictMath}.log
>  
> /jdk/src/hotspot/share/runtime/sharedRuntimeTrans.cpp:125:27: runtime error: division by zero
>     #0 0x7fff887f48bc in __ieee754_log(double) (/build_ubsan/images/jdk/lib/server/libjvm.so+0x69f48bc)
>     #1 0x7fff6b8fc768 (<unknown module>)
>  
> test
> java/lang/Math/PowTests.java: Tests for {Math, StrictMath}.pow
>  
> /jdk/src/hotspot/share/runtime/sharedRuntimeTrans.cpp:508:23: runtime error: division by zero
>     #0 0x7fff92fd61f0 in SharedRuntime::dpow(double, double) (/build_ubsan/images/jdk/lib/server/libjvm.so+0x69f61f0)
>     #1 0x7fff7701c8ec (<unknown module>)
> 
> The coding does intentional division by zero. 
> We should probably check for IEEE compliance  (or rewrite the coding);  but checking for compliance might be sufficient.

If this file requires certain IEEE divide-by-zero semantics, then should we also add static asserts for those?  Something like:
static_assert(-1.0 / 0.0 == -INFINITY, "IEEE 754 required");
static_assert(1.0 / 0.0 == INFINITY, "IEEE 754 required");
static_assert(std::isnan(0.0 / 0.0), "IEEE 754 required");

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

PR Comment: https://git.openjdk.org/jdk/pull/21500#issuecomment-2430079359


More information about the hotspot-dev mailing list