A Dimecres 26 Abril 2006 01:40, Andrew Straw va escriure:
> The following code fails on data files I created yesterday using
> pytables (IIRC a daily snapshot just prior to the 1.3 release -- it's
> called "1.3beta2"). The h5* tools seem to work (e.g. h5ls, h5dump and so
> on). The segfault occurs with pytables 1.2.3, 1.3, and today's svn
> current as of now.
>
> I've put a copy of a small (940 KB) example at
> http://mosca.caltech.edu/outgoing/DATA20060424_185459.h5
>
> The code that fails is:
>
> import tables
> results = tables.openFile('DATA20060424_185459.h5')
> for row in results.root.data2d:
> print '1'
>
> The segfault happens when trying to get the iterator from the Table
> class. (The print statement is never reached.)
This one is a PyTables flaw. I've not a definitive solution for this,
but the attached workaround seems to work well (and it doesn't leak :).
What was happening is that there are situations when a table node can
be killed between the initialization phase of the iterator of the Row
class and subsequents Row.__next__ calls. However, in the preKill
state the Table buffers are deleted, so the next iteration phase is
trying to write on a freed memory area, making PyTables to cause a
segmentation fault.
I should discuss with Ivan why this is happening, but meanwhile,
people can make use of the attached workaround.
Cheers,
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
Index: tables/Table.py
===================================================================
--- tables/Table.py (revision 1563)
+++ tables/Table.py (revision 1564)
@@ -1917,6 +1917,11 @@
def _g_preKillHook(self):
"""Code to be called before killing the node."""
+ if 'row' in self.__dict__ and self.row._middleOfIterator() > 0:
+ # We are in the middle of an iterator.
+ # Just flush the buffers but don't clean them!
+ self.flush()
+ return
self._g_cleanIOBuf()
return