[Python-bugs-list] [ python-Bugs-634905 ] segfault unpickling Numeric 'O' array

noreply@sourceforge.net noreply@sourceforge.net
Thu, 07 Nov 2002 05:08:24 -0800


Bugs item #634905, was opened at 2002-11-07 11:56
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=634905&group_id=5470

Category: Python Library
>Group: 3rd Party
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Raik Gruenberg (graik)
Assigned to: Nobody/Anonymous (nobody)
Summary: segfault unpickling Numeric 'O' array

Initial Comment:
A numpy array of objects can only be unpickled in the
same Python interpreter where it was pickled. Otherwise
a segmentation fault occurs when the unpickled array is
first accessed.

Python version: all tested (2.1 and 2.2 and 2.2.1)
OS: all tested (Linux rh 7.1 and 7.3,  MacOSX)
Numeric version: 22

EXAMPLE:
-------------

import sys
from Numeric import *
import cPickle

list = [{'name':'A', 'x':1}, {'name':'B', 'x':2}]

mask = [1,1]

rlist = compress( mask, list )
## rlist = rlist.tolist()    ## work-around

f = open( 'r.dat', 'w' )
r = cPickle.dump( rlist, f, 0) ## same with bin=1 or
pickle.dump
f.close()

sys.exit(0)

## RESTART PYTHON INTERPRETER HERE 
## (otherwise no segFault)
import cPickle

f = open( 'r.dat')
r = cPickle.load(f)  ## same with pickle.load
f.close()

## causes SEGFAULT:
print r

----------
The bug could probably also be submitted to the Numeric
team.

Greetings
Raik

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-11-07 14:08

Message:
Logged In: YES 
user_id=21627

This is not a bug in Python. pickle eventually executes

from Numeric import array_constructor
print array_constructor((2,), 'O',
'\x00\x18\xa2P\x00\x18\xa2\xe8', 0)

Numeric fails to return a sensible object for that call, so
this is clearly a bug in Numeric.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=634905&group_id=5470