From e773db1c484c91e787d3e6c93452abca53f1dba0 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Tue, 10 Dec 2024 10:40:15 +0100 Subject: [PATCH] Avoid segfaults daling with FileDecryptionProperties --- cpp/src/arrow/dataset/file_parquet.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/dataset/file_parquet.cc b/cpp/src/arrow/dataset/file_parquet.cc index ca391b4354c07..2090aced843c3 100644 --- a/cpp/src/arrow/dataset/file_parquet.cc +++ b/cpp/src/arrow/dataset/file_parquet.cc @@ -76,17 +76,17 @@ parquet::ReaderProperties MakeReaderProperties( } properties.set_buffer_size(parquet_scan_options->reader_properties->buffer_size()); + auto file_decryption_prop = + parquet_scan_options->reader_properties->file_decryption_properties(); + #ifdef PARQUET_REQUIRE_ENCRYPTION auto parquet_decrypt_config = parquet_scan_options->parquet_decryption_config; if (parquet_decrypt_config != nullptr) { - auto file_decryption_prop = + file_decryption_prop = parquet_decrypt_config->crypto_factory->GetFileDecryptionProperties( *parquet_decrypt_config->kms_connection_config, *parquet_decrypt_config->decryption_config, path, filesystem); - - parquet_scan_options->reader_properties->file_decryption_properties( - std::move(file_decryption_prop)); } #else if (parquet_scan_options->parquet_decryption_config != nullptr) { @@ -94,8 +94,7 @@ parquet::ReaderProperties MakeReaderProperties( } #endif - properties.file_decryption_properties( - parquet_scan_options->reader_properties->file_decryption_properties()); + properties.file_decryption_properties(file_decryption_prop); properties.set_thrift_string_size_limit( parquet_scan_options->reader_properties->thrift_string_size_limit()); @@ -527,9 +526,11 @@ Future> ParquetFileFormat::GetReader auto self = checked_pointer_cast(shared_from_this()); return source.OpenAsync().Then( - [=](const std::shared_ptr& input) mutable { - return parquet::ParquetFileReader::OpenAsync(input, std::move(properties), - metadata) + [self = self, properties = std::move(properties), source = source, + options = options, metadata = metadata, + parquet_scan_options = parquet_scan_options]( + const std::shared_ptr& input) mutable { + return parquet::ParquetFileReader::OpenAsync(input, properties, metadata) .Then( [=](const std::unique_ptr& reader) mutable -> Result> { @@ -544,7 +545,7 @@ Future> ParquetFileFormat::GetReader // here we know there are no other waiters on the reader. std::move(const_cast&>( reader)), - std::move(arrow_properties), &arrow_reader)); + arrow_properties, &arrow_reader)); // R build with openSUSE155 requires an explicit shared_ptr construction return std::shared_ptr(