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 1030 - Spyder 2.1rc1 issues with 'already deleted' scrollbars resulting in segfault on exit
: Spyder 2.1rc1 issues with 'already deleted' scrollbars resulting in segfault ...
Status: RESOLVED INVALID
Product: PySide
Classification: Unclassified
Component: PySide
: 1.0.8
: PC Linux
: P2 normal
Assigned To: Lauro Moura
:
:
:
  Show dependency treegraph
 
Reported: 2011-10-21 17:41 EEST by anatoly techtonik
Modified: 2011-11-14 19:37 EET (History)
8 users (show)

See Also:


Attachments
Minimal test case (888 bytes, text/x-python)
2011-11-12 00:17 EET, Lauro Moura
Details

Note You need to log in before you can comment on or make changes to this bug.
Description anatoly techtonik 2011-10-21 17:41:32 EEST
Sorry for not being able to produce a minimal example - I don't really have
much experience with PySide/Qt to work it out, but the bug is really easy to
reproduce, and it as easy as the following two commands to get into GDB session
yourself.

hg clone https://code.google.com/p/spyderlib/ 
cd spyderlib
gdb -ex r --args python bootstrap.py

1. Open some file
2. Open Outline view
3. Click any item in Outline
4. Switch to Internal Console
5. Notice traceback

6. Exit Spyder
7. Watch segfault


In PyQt mode everything is ok.

Spyder issue:
http://code.google.com/p/spyderlib/issues/detail?id=800
Comment 1 anatoly techtonik 2011-10-23 08:47:57 EEST
Better update to tag v2.1.0rc1, because a workaround was committed in Spyder
with description at http://code.google.com/p/spyderlib/issues/detail?id=800#c7
:

...with PySide, the editor's (QPlainTextEdit) vertical scroll bar is at some
point deleted and re-created. As a consequence, the first reference pointing to
it (stored in the editor widget's constructor) is later pointing to a Python
object associated with a deleted underlying C++ object...
Comment 2 Lauro Moura 2011-11-08 23:56:16 EET
It seems that the CodeEditor objects are being invalidated/destroyed (Don't
know yet if it's due to PySide or the expected behavior from spyderlib
(unlikely)), thus invalidating the scrollbars.
Comment 3 Lauro Moura 2011-11-12 00:17:54 EET
Created attachment 446 [details]
Minimal test case

Isolated the bug. Somehow PySide is invalidating the child of C++ objects when
the wrapper is invalidated but the C++ object isn't deleted (e.g. when the
parent is created in C++).

- A QWidget is added to a QTabWidget.
- An internal QStackedWidget steals the ownership of the added QWidget.
- This parent is accessed from python, leading to the creation of a "detached"
wrapper to it.
- This wrapper is deleted. It shouldn't delete the C++ object, but also
shouldn't invalidate the children. Which it is doing.

So, the CodeEditor (from SpyderLib2) was being invalidated when its parent was
invalidated (by going out of scope) after OutlineExplorter.clicked return.

The most direct fix is to avoid invalidating the children of these detached
wrappers.
Comment 4 Lauro Moura 2011-11-14 19:37:34 EET
Actually, avoiding to invalidate all children would open the program to
segfaults as we can't track when a C++ object created by Qt (instead of one
created in PySide) is deleted.

In SpyderLib2 case, the scrollbar saved in vsb is created anonymously in Qt,
and once it's parent is invalidated, we must invalidate it too as we don't know
when it will be deleted.

Marking as invalid.