mapleFU commented on code in PR #37360:
URL: https://github.com/apache/arrow/pull/37360#discussion_r1309883843
##########
cpp/src/arrow/io/memory_test.cc:
##########
@@ -283,12 +283,42 @@ TEST(TestBufferReader, WillNeed) {
}
{
std::string data = "data123456";
- BufferReader reader(reinterpret_cast<const uint8_t*>(data.data()),
- static_cast<int64_t>(data.size()));
+ auto reader = BufferReader::FromString(data);
- ASSERT_OK(reader.WillNeed({{0, 4}, {4, 6}}));
- ASSERT_RAISES(IOError, reader.WillNeed({{11, 1}})); // Out of bounds
+ ASSERT_OK(reader->WillNeed({{0, 4}, {4, 6}}));
+ ASSERT_RAISES(IOError, reader->WillNeed({{11, 1}})); // Out of bounds
+ }
+}
+
+void TestBufferReaderLifetime(
+ std::function<std::unique_ptr<BufferReader>(std::string&)> fn,
+ bool supports_zero_copy) {
Review Comment:
Nice catch, I forgot to remove it previously
##########
cpp/src/arrow/compute/function_internal.cc:
##########
@@ -83,8 +83,10 @@ Result<std::unique_ptr<FunctionOptions>>
GenericOptionsType::Deserialize(
Result<std::unique_ptr<FunctionOptions>> DeserializeFunctionOptions(
const Buffer& buffer) {
- io::BufferReader stream(buffer);
- ARROW_ASSIGN_OR_RAISE(auto reader,
ipc::RecordBatchFileReader::Open(&stream));
+ // Copying the buffer here is not ideal, but we need to do it to avoid
+ // lifetime issues with the zero-copy buffer read.
Review Comment:
Change to `use-after-free` here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]