Overlapping copy with object_ arrays
Hello, Having a problem with overlapping copies. Memory being freed twice ??? See below: ActivePython 2.4.3 Build 11 (ActiveState Software Inc.) based on Python 2.4.3 (#1, Apr 3 2006, 18:07:14) [GCC 4.0.1 (Apple Computer, Inc. build 5247)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import numpy print numpy.__version__ 1.0.1 x = numpy.zeros(10, numpy.object_) x[:] = [], # set the array to empy lists x[0] is x[1] # everyone is of course identical True x[3:-1] = x[4:] # overlappping copy x # all is right in the universe array([[], [], [], [], [], [], [], [], [], []], dtype=object) for i in range(10): x[i] = [] # set the array with a loop ... x[0] is x[1] # everyone is of course different False x[3:-1] = x[4:] # overlapping copy x # oops, situation not OK, heap apparently corrupted by overlapping copy Bus error
Jim ____________________________________________________________________________________ Cheap talk? Check out Yahoo! Messenger's low PC-to-Phone call rates. http://voice.yahoo.com
James Flowers wrote:
Hello,
Having a problem with overlapping copies. Memory being freed twice ??? See below:
Thanks for the test. This problem is fixed and will be checked into SVN as soon as I can figure out why I'm not able to access SVN from my work machine. The problem is that object array copies were done by first decrementing the reference count of all elements of the destination array and then incrementing the reference count of all elements of the destination array once the copy was complete. For over-lapping copies (containing only a single reference to an object). This created a problem as the reference count went to 0 before the copy occurred. I've changed the code so that the reference count of the source is increased and the reference count of the destination is decreased before the copy is made. Then, the reference counts are correct after the copy is completed even for over-lapping copies. -Travis
participants (2)
-
James Flowers
-
Travis Oliphant