Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 4cf1deb

Browse files
SAT-2855 - Memory leaks cause segfaults in unit tests (#885)
1 parent cb733a0 commit 4cf1deb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

sdc/hiframes/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from numba.core.typing import signature
3434
from numba.core.typing.templates import infer_global, AbstractTemplate, CallableTemplate
3535
from numba.extending import overload, intrinsic
36-
from numba.core.imputils import (lower_builtin, impl_ret_borrowed)
36+
from numba.core.imputils import (lower_builtin, impl_ret_borrowed, impl_ret_new_ref)
3737

3838
import sdc
3939
from sdc.str_ext import string_type, list_string_array_type
@@ -168,7 +168,7 @@ def generic(self, args, kws):
168168
def lower_fix_df_array(context, builder, sig, args):
169169
func = fix_df_array_overload(sig.args[0])
170170
res = context.compile_internal(builder, func, sig, args)
171-
return impl_ret_borrowed(context, builder, sig.return_type, res)
171+
return impl_ret_new_ref(context, builder, sig.return_type, res)
172172

173173

174174
def fix_df_array_overload(column):

sdc/hiframes/boxing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,21 @@ def unbox_series(typ, val, c):
338338
if typ.index == string_array_type:
339339
index_obj = c.pyapi.object_getattr_string(val, "index")
340340
series.index = unbox_str_series(string_array_type, index_obj, c).value
341+
c.pyapi.decref(index_obj)
341342

342343
if isinstance(typ.index, types.Array):
343344
index_obj = c.pyapi.object_getattr_string(val, "index")
344345
index_data = c.pyapi.object_getattr_string(index_obj, "_data")
345346
series.index = unbox_array(typ.index, index_data, c).value
347+
c.pyapi.decref(index_obj)
348+
c.pyapi.decref(index_data)
346349

347350
if typ.is_named:
348351
name_obj = c.pyapi.object_getattr_string(val, "name")
349352
series.name = numba.cpython.unicode.unbox_unicode_str(
350353
string_type, name_obj, c).value
354+
c.pyapi.decref(name_obj)
355+
351356
# TODO: handle index and name
352357
c.pyapi.decref(arr_obj)
353358
return NativeValue(series._getvalue())

sdc/str_arr_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def box_str_arr(typ, val, c):
884884
string_array.data, string_array.null_bitmap])
885885

886886
# TODO: double check refcounting here
887-
# c.context.nrt.decref(c.builder, typ, val)
887+
c.context.nrt.decref(c.builder, typ, val)
888888
return arr # c.builder.load(arr)
889889

890890

0 commit comments

Comments
 (0)