Skip to content

Commit

Permalink
Fix hang due to missing clean-up in exception path
Browse files Browse the repository at this point in the history
Must close and free before raising the error here.
  • Loading branch information
ihnorton committed May 14, 2019
1 parent 453e8da commit 22b31da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tiledb/libtiledb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3405,6 +3405,7 @@ cdef class Array(object):
cdef uint64_t _timestamp = 0
if timestamp is not None:
_timestamp = <uint64_t> timestamp

# allocate and then open the array
cdef tiledb_array_t* array_ptr = NULL
cdef int rc = TILEDB_OK
Expand All @@ -3431,9 +3432,12 @@ cdef class Array(object):

# view on a single attribute
if attr and not any(attr == schema.attr(i).name for i in range(schema.nattr)):
tiledb_array_close(ctx_ptr, array_ptr)
tiledb_array_free(&array_ptr)
raise KeyError("No attribute matching '{}'".format(attr))
else:
self.view_attr = unicode(attr) if (attr is not None) else None

self.ctx = ctx
self.uri = unicode(uri)
self.mode = unicode(mode)
Expand Down
2 changes: 1 addition & 1 deletion tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ def test_view_multiattr(self):
T[:] = {'': anon_ar, 'named': named_ar}

with self.assertRaises(KeyError):
T = tiledb.DenseArray(uri, 'r', attr="foo111")
T = tiledb.DenseArray(uri, 'r', attr="foo111", ctx=ctx)

with tiledb.DenseArray(uri, 'r', attr="named", ctx=ctx) as T:
assert_array_equal(T, named_ar)
Expand Down

0 comments on commit 22b31da

Please sign in to comment.