This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 960122fe fix: Ensure metal device's align buffers exports aligned 
buffer pointers correctly (#904)
960122fe is described below

commit 960122fed9265f2fb70924c97de380ac12daa5c1
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed Jul 15 19:55:02 2026 +0000

    fix: Ensure metal device's align buffers exports aligned buffer pointers 
correctly (#904)
    
    The existing implementation of `ArrowDeviceMetalAlignArrayBuffers()` did
    not properly flush the buffer pointer in the `ArrowArray`, so the
    `array->buffers[i]` pointer pointed to potentially freed data. This is
    not a commonly (if ever) used function.
---
 .github/workflows/r-check.yaml     | 2 +-
 src/nanoarrow/device/metal.cc      | 3 +--
 src/nanoarrow/device/metal_test.cc | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/r-check.yaml b/.github/workflows/r-check.yaml
index 41e19e61..a16bb126 100644
--- a/.github/workflows/r-check.yaml
+++ b/.github/workflows/r-check.yaml
@@ -65,7 +65,7 @@ jobs:
         if: matrix.config.os != 'windows-latest'
         env:
           PKG_CPPFLAGS: "-DNANOARROW_DEBUG"
-          PKG_CFLAGS: "-Werror -Wall -Wextra -Wpedantic -Wconversion 
-Wno-unused-parameter -Wno-sign-conversion -Wno-cast-function-type 
-Wno-misleading-indentation -Wno-conversion -Wno-unused-const-variable"
+          PKG_CFLAGS: "-Werror -Wall -Wextra -Wpedantic -Wconversion 
-Wno-unused-parameter -Wno-sign-conversion -Wno-cast-function-type 
-Wno-misleading-indentation -Wno-conversion -Wno-unused-const-variable 
-Wno-c23-extensions"
         run: |
           R CMD INSTALL r --preclean
         shell: bash
diff --git a/src/nanoarrow/device/metal.cc b/src/nanoarrow/device/metal.cc
index 5881481b..ffbadddf 100644
--- a/src/nanoarrow/device/metal.cc
+++ b/src/nanoarrow/device/metal.cc
@@ -127,8 +127,7 @@ ArrowErrorCode ArrowDeviceMetalAlignArrayBuffers(struct 
ArrowArray* array) {
     NANOARROW_RETURN_NOT_OK(ArrowDeviceMetalInitBuffer(&new_buffer));
     NANOARROW_RETURN_NOT_OK(
         ArrowBufferAppend(&new_buffer, buffer->data, buffer->size_bytes));
-    ArrowBufferReset(buffer);
-    ArrowBufferMove(&new_buffer, buffer);
+    NANOARROW_RETURN_NOT_OK(ArrowArraySetBuffer(array, i, &new_buffer));
   }
 
   for (int64_t i = 0; i < array->n_children; i++) {
diff --git a/src/nanoarrow/device/metal_test.cc 
b/src/nanoarrow/device/metal_test.cc
index 009d6a75..bd3f0edd 100644
--- a/src/nanoarrow/device/metal_test.cc
+++ b/src/nanoarrow/device/metal_test.cc
@@ -206,7 +206,7 @@ TEST(NanoarrowDeviceMetal, DeviceCpuArrayBuffers) {
       ArrowArrayFinishBuilding(array.get(), NANOARROW_VALIDATION_LEVEL_FULL, 
nullptr),
       NANOARROW_OK);
 
-  // Make sure that ArrowDeviceMetalInitArrayBuffers() copies existing content
+  // Make sure that ArrowDeviceMetalAlignArrayBuffers() copies existing content
   ASSERT_EQ(ArrowDeviceMetalAlignArrayBuffers(array.get()), NANOARROW_OK);
 
   auto data_ptr = reinterpret_cast<const 
int32_t*>(array->children[0]->buffers[1]);

Reply via email to