PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 614 - FAil to register 2 objects in the same address
: FAil to register 2 objects in the same address
Status: CLOSED INVALID
Product: PySide
Classification: Unclassified
Component: Shiboken
: HEAD
: All All
: P3 normal
Assigned To: Marcelo Lira
:
:
: 575
  Show dependency treegraph
 
Reported: 2011-01-14 09:41 EET by renato filho
Modified: 2011-01-21 15:44 EET (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description renato filho 2011-01-14 09:41:10 EET
Sometimes 2 object use the same memory address.
This is common when a structure has attributes in the beginning, then the first
attribute use the same address as your father structure.

Shiboken uses a hashmap with object c++ mapped to python object, then this get
in a mess when you try register 2 object with the same c++ address.


Ex:

class A { public: Object *o; };

A  myA = new A();


Both myA and myA->o has the same memory address.
Comment 1 Matti Airas 2011-01-14 09:46:26 EET
Thanks for the bug report.

What is the impact of this issue? In which situations does it cause problems?

Keeping unconfirmed now due to the vague report.
Comment 2 renato filho 2011-01-14 11:17:52 EET
The impact is in all binding code.

Until now we did think about this situation because we forgot about this case.

Then in all classes which have a attribute in the beginning will break the
binding, and can cause a mess on the binding manager.
Comment 3 Matti Airas 2011-01-14 11:25:46 EET
Soo... in which kinds of situations would the bug manifest itself? Bug 575 is
an example, of course, but how can it be generalized?

Anyway, prioritizing P2.
Comment 4 Matti Airas 2011-01-14 11:41:31 EET
Augh - NOW it's P2.
Comment 5 Hugo Parente Lima 2011-01-14 11:49:11 EET
Shiboken does the link between python objects and C++ objects based on the C++
object address, but in C++ two objects can have the same memory address in some
cases. e.g.:

class A { };
class B { A* a; }

B b;

(void*)&b == (void*)b.a // this is true.

So if a class have a public attribute and it's the first attribute of a class,
it wont work on Shiboken based bindings.

To fix it we need to change how to we store the info used to recover the python
object given a C++ object, i. e. change one of the core parts of shiboken, the
BindingManager class.
Comment 6 Matti Airas 2011-01-14 11:52:56 EET
(In reply to comment #5)
> To fix it we need to change how to we store the info used to recover the python
> object given a C++ object, i. e. change one of the core parts of shiboken, the
> BindingManager class.

Can this change be performed without breaking the API/ABI?
Comment 7 Hugo Parente Lima 2011-01-14 14:36:42 EET
Probably no, but first we need to find a solution, them check how to do it
without break the ABI.
Comment 8 Hugo Parente Lima 2011-01-14 19:02:22 EET
(In reply to comment #5)
> Shiboken does the link between python objects and C++ objects based on the C++
> object address, but in C++ two objects can have the same memory address in some
> cases. e.g.:
> 
> class A { };
> class B { A* a; }
> 
> B b;
> 
> (void*)&b == (void*)b.a // this is true.

Correcting myself:

b.a is of type A**, so this example is wrong.

To trigger this bug a must be a value not a reference or pointer, but... the
fix of bug 575 is just not register the returned PyObject in the BindingManager
in the attribute getter function, so this bug is invalid.

Ok, my explanation was near impossible to understand even knowing the internals
of Shiboken and I impossible without... but I tried =]
Comment 9 Matti Airas 2011-01-17 06:29:21 EET
(In reply to comment #8)

> To trigger this bug a must be a value not a reference or pointer, but... the
> fix of bug 575 is just not register the returned PyObject in the BindingManager
> in the attribute getter function, so this bug is invalid.
> 
> Ok, my explanation was near impossible to understand even knowing the internals
> of Shiboken and I impossible without... but I tried =]

Thanks a lot for that. :-D
Comment 10 renato filho 2011-01-21 15:44:51 EET
release beta4