Skip to content

Commit 852653d

Browse files
committed
Update pyarrow patch
1 parent b3c6bb7 commit 852653d

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

graalpython/lib-graalpython/patches/pyarrow/pyarrow-12.0.0.patch

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,35 @@ index 46ea021..58a3fb5 100644
1111
SendSignal(exc_value.signum)
1212
else:
1313
SendSignalToThread(exc_value.signum,
14-
diff --git a/pyarrow/tests/test_memory.py b/pyarrow/tests/test_memory.py
15-
index 092c50d..931b3fa 100644
16-
--- a/pyarrow/tests/test_memory.py
17-
+++ b/pyarrow/tests/test_memory.py
18-
@@ -44,6 +44,9 @@ def allocate_bytes(pool, nbytes):
19-
"""
20-
Temporarily allocate *nbytes* from the given *pool*.
14+
diff --git a/pyarrow/memory.pxi b/pyarrow/memory.pxi
15+
index 1ddcb01..6805e42 100644
16+
--- a/pyarrow/memory.pxi
17+
+++ b/pyarrow/memory.pxi
18+
@@ -20,6 +20,10 @@
19+
# cython: embedsignature = True
20+
21+
22+
+cdef extern from "Python.h":
23+
+ void Py_INCREF(object)
24+
+
25+
+
26+
cdef class MemoryPool(_Weakrefable):
2127
"""
22-
+ # GraalPy change: the buffers don't maintain a python reference to their
23-
+ # pool, so they may get destroyed after their pool, which segfaults
24-
+ raise RuntimeError("GraalPy: destructors segfault")
25-
arr = pa.array([b"x" * nbytes], type=pa.binary(), memory_pool=pool)
26-
# Fetch the values buffer from the varbinary array and release the rest,
27-
# to get the desired allocation amount
28+
Base class for memory allocation.
29+
@@ -35,6 +39,13 @@ cdef class MemoryPool(_Weakrefable):
30+
31+
cdef void init(self, CMemoryPool* pool):
32+
self.pool = pool
33+
+ # GraalPy change: pyarrow doesn't maintain python references from
34+
+ # buffers to pools, but they dereference the pointer to the pool in the
35+
+ # destructor. They just assume buffers will get GC'ed before their
36+
+ # pools. You can easily get a segfault even on CPython if you make
37+
+ # a buffer outlive its pool. Since we can't guarantee destruction
38+
+ # order, we just leak the pool.
39+
+ Py_INCREF(self)
40+
41+
def release_unused(self):
42+
"""
2843
diff --git a/pyarrow_build_backend.py b/pyarrow_build_backend.py
2944
new file mode 100644
3045
index 0000000..c9826ce

0 commit comments

Comments
 (0)