On 10/13/11 4:50 AM, Olly Betts wrote:
# I've reproduced this with some recent versions:
found 2.8.10.1-3
found 2.8.10.1+dfsg-4
found 2.8.12.1-1
thanks

On Fri, Jul 30, 2004 at 07:25:12PM +0930, Ron wrote:
I can reproduce this one in 2.4.2.4, in 2.4 branch head, and
in 2.5.1.  Should he just not be doing this (DateTime() doesn't
return a valid object reference?) or is this a real bug?

I suspect it's a reference counting bug in the SWIG generated code.  I've
not looked at the code here though.

When creating a new wxDateTime object with a specified number of seconds
since 01-01-1970, SetTimeT returns random dates and eventually
segfaults.  See the following interaction between me and the python
interpreter:

import wx
d=wx.DateTime().SetTimeT(0)
d
<wxDateTime: "wo 28 mei 633986 15:01:41 CET" at _828ea68_wxDateTime_p>

Interestingly, if I run under valgrind, I consistently get the answer I'd
expect.  Python is a bit noisy under valgrind, so it's hard to see if it
is reporting an issue, but I suspect what is happening is that d gets
released and normally is partly overwritten by the time we try to print it
out, but valgrind's malloc replacement doesn't overwrite that part of the
object.


SWIG has a problem with methods that return a reference to self, and it treats the intermediate results as temporaries and creates new proxies for them. When chaining calls together like that it ends up thinking that the original object is no longer referenced and it lets Python delete it. Since the reference saved in d is actually a proxy to the same C++ object then it ends up with an invalid pointer.

I'll add the code to stop SWIG's confusion in this case. In the meantime you can work around it by not chaining the constructor and method calls together so you can hold on to the original reference.

 >>> import wx
 >>> d = wx.DateTime()
 >>> d.SetTimeT(0)
<wx.DateTime: "Wednesday, December 31, 1969 04:00:00 PM" at _e06b3200_p_wxDateTime>
 >>> print d
 Wednesday, December 31, 1969 04:00:00 PM


--
Robin Dunn
Software Craftsman
http://wxPython.org




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to