Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #166 from mrocklin/avoid-segfault
Browse files Browse the repository at this point in the history
Remove with nogil statement to avoid segfault
  • Loading branch information
FrancescAlted committed Mar 26, 2015
2 parents 648b7f9 + 46b6b59 commit 09550e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Changes from 0.8.1 to 0.9.0
- Add ``safe=`` keyword argument to control dtype/stride checking on append
(#163 @mrocklin)

- Hold GIL during c-blosc compression/decompression, avoiding some segfaults
(#166 @mrocklin)

Changes from 0.8.0 to 0.8.1
===========================

Expand Down
20 changes: 8 additions & 12 deletions bcolz/carray_ext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,8 @@ cdef class chunk:
raise ValueError(
"Compressor '%s' is not available in this build" % cname)
dest = <char *> malloc(nbytes + BLOSC_MAX_OVERHEAD)
with nogil:
ret = blosc_compress(clevel, shuffle, itemsize, nbytes,
data, dest, nbytes + BLOSC_MAX_OVERHEAD)
ret = blosc_compress(clevel, shuffle, itemsize, nbytes,
data, dest, nbytes + BLOSC_MAX_OVERHEAD)
if ret <= 0:
raise RuntimeError(
"fatal error during Blosc compression: %d" % ret)
Expand Down Expand Up @@ -454,8 +453,7 @@ cdef class chunk:

dest = <char *> malloc(self.nbytes)
# Fill dest with uncompressed data
with nogil:
ret = blosc_decompress(self.data, dest, self.nbytes)
ret = blosc_decompress(self.data, dest, self.nbytes)
if ret < 0:
raise RuntimeError(
"fatal error during Blosc decompression: %d" % ret)
Expand All @@ -480,11 +478,10 @@ cdef class chunk:
return

# Fill dest with uncompressed data
with nogil:
if bsize == self.nbytes:
ret = blosc_decompress(self.data, dest, bsize)
else:
ret = blosc_getitem(self.data, nstart, nitems, dest)
if bsize == self.nbytes:
ret = blosc_decompress(self.data, dest, bsize)
else:
ret = blosc_getitem(self.data, nstart, nitems, dest)
if ret < 0:
raise RuntimeError(
"fatal error during Blosc decompression: %d" % ret)
Expand Down Expand Up @@ -709,8 +706,7 @@ cdef class chunks(object):
# Fill lastchunk with data on disk
scomp = self.read_chunk(self.nchunks)
compressed = PyString_AsString(scomp)
with nogil:
ret = blosc_decompress(compressed, lastchunk, chunksize)
ret = blosc_decompress(compressed, lastchunk, chunksize)
if ret < 0:
raise RuntimeError(
"error decompressing the last chunk (error code: "
Expand Down

0 comments on commit 09550e2

Please sign in to comment.