From ec8704a45c93915067f987e35bfb37bfec2e05ae Mon Sep 17 00:00:00 2001 From: "Robert (Bobby) Evans" Date: Fri, 17 Feb 2023 15:27:57 -0600 Subject: [PATCH] Fix a leak in a test and clarify some test names (#12781) Fix a small leak of host memory in a java unit test. Also updates some tests that verify that a double free is safe, but don't make it clear from the logs that the double free is expected to be there. This is so we don't have to spend too much time debugging if this double free is expected or not. Authors: - Robert (Bobby) Evans (https://github.com/revans2) Approvers: - Kuhu Shukla (https://github.com/kuhushukla) - Jim Brennan (https://github.com/jbrennan333) - Jason Lowe (https://github.com/jlowe) - Raza Jafri (https://github.com/razajafri) - Gera Shegalov (https://github.com/gerashegalov) URL: https://github.com/rapidsai/cudf/pull/12781 --- java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java | 4 ++-- java/src/test/java/ai/rapids/cudf/ScalarTest.java | 4 ++-- java/src/test/java/ai/rapids/cudf/TableTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index db64dcb08c7..937077c89c9 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -1045,8 +1045,8 @@ void decimal128Cv() { BigInteger bigInteger2 = new BigInteger("14"); BigInteger bigInteger3 = new BigInteger("152345742357340573405745"); final BigInteger[] bigInts = new BigInteger[] {bigInteger1, bigInteger2, bigInteger3}; - try (ColumnVector v = ColumnVector.decimalFromBigInt(-dec32Scale1, bigInts)) { - HostColumnVector hostColumnVector = v.copyToHost(); + try (ColumnVector v = ColumnVector.decimalFromBigInt(-dec32Scale1, bigInts); + HostColumnVector hostColumnVector = v.copyToHost()) { assertEquals(bigInteger1, hostColumnVector.getBigDecimal(0).unscaledValue()); assertEquals(bigInteger2, hostColumnVector.getBigDecimal(1).unscaledValue()); assertEquals(bigInteger3, hostColumnVector.getBigDecimal(2).unscaledValue()); diff --git a/java/src/test/java/ai/rapids/cudf/ScalarTest.java b/java/src/test/java/ai/rapids/cudf/ScalarTest.java index 86c340bb321..f4b652a7d03 100644 --- a/java/src/test/java/ai/rapids/cudf/ScalarTest.java +++ b/java/src/test/java/ai/rapids/cudf/ScalarTest.java @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public void testDoubleClose() { } @Test - public void testIncRef() { + public void testIncRefAndDoubleFree() { Scalar s = Scalar.fromNull(DType.INT32); try (Scalar ignored1 = s) { try (Scalar ignored2 = s.incRefCount()) { diff --git a/java/src/test/java/ai/rapids/cudf/TableTest.java b/java/src/test/java/ai/rapids/cudf/TableTest.java index 4f00bc7493d..c31bcf4f78d 100644 --- a/java/src/test/java/ai/rapids/cudf/TableTest.java +++ b/java/src/test/java/ai/rapids/cudf/TableTest.java @@ -244,7 +244,7 @@ void testOrderByWithNullsAndStrings() { } @Test - void testTableCreationIncreasesRefCount() { + void testTableCreationIncreasesRefCountWithDoubleFree() { //tests the Table increases the refcount on column vectors assertThrows(IllegalStateException.class, () -> { try (ColumnVector v1 = ColumnVector.build(DType.INT32, 5, Range.appendInts(5));