RFR: 8336240: Test com/sun/crypto/provider/Cipher/DES/PerformanceTest.java fails with java.lang.ArithmeticException

Rajan Halade rhalade at openjdk.org
Mon Jul 15 08:09:51 UTC 2024


On Thu, 11 Jul 2024 09:51:10 GMT, Fernando Guallini <fguallini at openjdk.org> wrote:

> The manual test Cipher/DES/PerformanceTest.java fails with ArithmeticException due to potential division by zero. The issue arises when calculating the elapsed time using end - start, which could result in zero milliseconds if start and end are identical due to the high speed of execution. This leads to a division error in the following code snippet:
> 
> 
> start = System.currentTimeMillis();
> end = System.currentTimeMillis();
> int speed = (int)((data.length * count)/(end - start));
> 
> The fix is to provide a default value in case _end_ is not higher than _start_.

test/jdk/com/sun/crypto/provider/Cipher/DES/PerformanceTest.java line 186:

> 184:         end = System.currentTimeMillis();
> 185: 
> 186:         // To avoid diving by zero if end is equal to start

Test is performing 100 and 1000 rounds of `update`. I don't think we are seeing same start and end. Please test further to determine root cause. Could be the case of overflow if `update` is taking long time.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20135#discussion_r1677450326



More information about the security-dev mailing list