From d8192f158f16946cab7d6d4cfbca63cd798c9110 Mon Sep 17 00:00:00 2001 From: Robert Bindar Date: Thu, 28 Mar 2024 14:56:03 +0200 Subject: [PATCH 1/4] fix crash --- test/src/unit-vfs.cc | 6 +++++- tiledb/sm/filesystem/azure.cc | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/src/unit-vfs.cc b/test/src/unit-vfs.cc index b1c9b8b1f54..31ec50110cf 100644 --- a/test/src/unit-vfs.cc +++ b/test/src/unit-vfs.cc @@ -442,6 +442,11 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) { Config config = set_config_params(disable_multipart, max_parallel_ops); VFS vfs{&g_helper_stats, &compute_tp, &io_tp, config}; + // Getting file_size on a nonexistent blob shouldn't crash on Azure + uint64_t nbytes = 0; + URI non_existent = URI(path.to_string() + "non_existent"); + require_tiledb_ok(vfs.file_size(non_existent, &nbytes)); + // Set up bool exists = false; if (path.is_gcs() || path.is_s3() || path.is_azure()) { @@ -494,7 +499,6 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) { CHECK(exists); // Get file sizes - uint64_t nbytes = 0; require_tiledb_ok(vfs.file_size(largefile, &nbytes)); CHECK(nbytes == (buffer_size)); require_tiledb_ok(vfs.file_size(smallfile, &nbytes)); diff --git a/tiledb/sm/filesystem/azure.cc b/tiledb/sm/filesystem/azure.cc index 8b8f2d88245..ea461f24b40 100644 --- a/tiledb/sm/filesystem/azure.cc +++ b/tiledb/sm/filesystem/azure.cc @@ -700,9 +700,9 @@ Status Azure::blob_size(const URI& uri, uint64_t* const nbytes) const { if (response.Blobs.empty()) { error_message = "Blob does not exist."; + } else { + *nbytes = static_cast(response.Blobs[0].BlobSize); } - - *nbytes = static_cast(response.Blobs[0].BlobSize); } catch (const ::Azure::Storage::StorageException& e) { error_message = e.Message; } From f55a0cf389c1b96544b32d9767b61bbce5c54167 Mon Sep 17 00:00:00 2001 From: Robert Bindar Date: Fri, 29 Mar 2024 17:27:10 +0200 Subject: [PATCH 2/4] fix test --- test/src/unit-vfs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/unit-vfs.cc b/test/src/unit-vfs.cc index 31ec50110cf..434e35d907a 100644 --- a/test/src/unit-vfs.cc +++ b/test/src/unit-vfs.cc @@ -445,7 +445,7 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) { // Getting file_size on a nonexistent blob shouldn't crash on Azure uint64_t nbytes = 0; URI non_existent = URI(path.to_string() + "non_existent"); - require_tiledb_ok(vfs.file_size(non_existent, &nbytes)); + CHECK(!vfs.file_size(non_existent, &nbytes).ok()); // Set up bool exists = false; From 82edb788f6b30576723b7247f870f669ef18a452 Mon Sep 17 00:00:00 2001 From: Robert Bindar Date: Mon, 1 Apr 2024 13:35:17 +0300 Subject: [PATCH 3/4] speciale case posix cause it throws --- test/src/unit-vfs.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/src/unit-vfs.cc b/test/src/unit-vfs.cc index 434e35d907a..1cbb7aec2ab 100644 --- a/test/src/unit-vfs.cc +++ b/test/src/unit-vfs.cc @@ -445,7 +445,11 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) { // Getting file_size on a nonexistent blob shouldn't crash on Azure uint64_t nbytes = 0; URI non_existent = URI(path.to_string() + "non_existent"); - CHECK(!vfs.file_size(non_existent, &nbytes).ok()); + if (path.is_file()) { + CHECK_THROWS(vfs.file_size(non_existent, &nbytes)); + } else { + CHECK(!vfs.file_size(non_existent, &nbytes).ok()); + } // Set up bool exists = false; From 1d2dac9689b68245f5a33d6c88d036fb24620f53 Mon Sep 17 00:00:00 2001 From: Robert Bindar Date: Mon, 1 Apr 2024 14:09:00 +0300 Subject: [PATCH 4/4] fix on windows --- test/src/unit-vfs.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/src/unit-vfs.cc b/test/src/unit-vfs.cc index 1cbb7aec2ab..939bfd58e6d 100644 --- a/test/src/unit-vfs.cc +++ b/test/src/unit-vfs.cc @@ -446,7 +446,11 @@ TEMPLATE_LIST_TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]", AllBackends) { uint64_t nbytes = 0; URI non_existent = URI(path.to_string() + "non_existent"); if (path.is_file()) { +#ifdef _WIN32 + CHECK(!vfs.file_size(non_existent, &nbytes).ok()); +#else CHECK_THROWS(vfs.file_size(non_existent, &nbytes)); +#endif } else { CHECK(!vfs.file_size(non_existent, &nbytes).ok()); }