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

David Holmes dholmes at openjdk.org
Tue Oct 15 12:21:11 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.

src/hotspot/share/runtime/sharedRuntimeTrans.cpp line 122:

> 120:   unsigned lx;
> 121: 
> 122:   static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 required");

I'm not sure what the implications of this actually are. Do we really need it? Maybe @jddarcy can comment?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21500#discussion_r1801055026


More information about the hotspot-dev mailing list