Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 301476 - QSvgWidget produce segfaults : x11-libs/qt-svg
Summary: QSvgWidget produce segfaults : x11-libs/qt-svg
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Qt Bug Alias
URL: http://bugreports.qt.nokia.com/browse...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-19 02:54 UTC by antonmx
Modified: 2011-01-16 00:36 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
updated ebuild (qt-svg-4.6.0-r1.ebuild,1.45 KB, text/plain)
2010-01-19 02:55 UTC, antonmx
Details
patch for the src/svg/qsvgwidget.cpp (qt-svg-4.6.0.src-svg-qsvgwidget.cpp.patch,2.22 KB, patch)
2010-01-19 02:56 UTC, antonmx
Details | Diff
patch for the src/svg/qsvgwidget.h (qt-svg-4.6.0.src-svg-qsvgwidget.h.patch,434 bytes, patch)
2010-01-19 02:58 UTC, antonmx
Details | Diff
test application segfaulting with broken Qt lib (svgtest.cpp,195 bytes, text/plain)
2010-05-10 18:44 UTC, Markus Lohse
Details
cave info qt-gui (cave-info.txt,24.86 KB, text/plain)
2010-11-25 20:00 UTC, Aleksandar Petrinic
Details
qt-svg-4.7.1.ebuild (qt-svg-4.7.1.ebuild,1.47 KB, text/plain)
2010-12-13 14:14 UTC, Jaak Ristioja
Details
patch against qt-svg-4.7.1 (qt-svg-4.7.1.ebuild.patch,1.19 KB, patch)
2011-01-10 23:32 UTC, Davide Pesavento
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description antonmx 2010-01-19 02:54:27 UTC
QSvgWidget produce segfaults. See the description and discussion at

http://bugreports.qt.nokia.com/browse/QTBUG-6774

Looks like the bug is specific to Gentoo.

In the discussion Sergiy Dzhantimirov proposed the solution. I confirmed it and formed the patches (see files attached).
Comment 1 antonmx 2010-01-19 02:55:31 UTC
Created attachment 216864 [details]
updated ebuild
Comment 2 antonmx 2010-01-19 02:56:51 UTC
Created attachment 216865 [details, diff]
patch for the src/svg/qsvgwidget.cpp
Comment 3 antonmx 2010-01-19 02:58:04 UTC
Created attachment 216866 [details, diff]
patch for the src/svg/qsvgwidget.h
Comment 4 Davide Pesavento gentoo-dev 2010-01-19 10:53:08 UTC
I don't see how this bug is specific to Gentoo... please explain.
Comment 5 Markos Chandras (RETIRED) gentoo-dev 2010-01-19 17:44:02 UTC
Upstream doesn't seem to have applied it on qt-svg module so we need to add this on qt-svg-4.6.1 as well
Comment 6 antonmx 2010-01-19 23:11:27 UTC
(In reply to comment #4)
> I don't see how this bug is specific to Gentoo... please explain.
> 

The bug was reproduced only on Gentoo (5 times, see the original report at qt.nokia.com). No confirmations on other platforms. Of cause it does not mean it is Gentoo-specific, but look like it is.
Comment 7 Davide Pesavento gentoo-dev 2010-02-10 23:44:51 UTC
Upstream closed the bug report as "not a Qt bug". However I can consistently reproduce the crash with Qt 4.6.1, using the following reduced testcase:

#include <QApplication>
#include <QSvgWidget>

int main(int argc, char *argv[])
{
        QApplication app(argc, argv);
        QSvgWidget();
        return 0;
}
Comment 8 Markos Chandras (RETIRED) gentoo-dev 2010-03-18 11:48:45 UTC
Is this still reproducible with 4.6.2? I am not confident with applying the attached patches since upstream rejected them
Comment 9 Davide Pesavento gentoo-dev 2010-03-18 14:17:33 UTC
(In reply to comment #8)
> Is this still reproducible with 4.6.2?

Yes.
Comment 10 antonmx 2010-03-18 23:01:39 UTC
(In reply to comment #8)
> Is this still reproducible with 4.6.2? I am not confident with applying the
> attached patches since upstream rejected them
> 

Yes. I just keep applying the same patch to each next version.
Comment 11 Markus Lohse 2010-03-21 18:32:42 UTC
I can confirm this on my system:
* glib-2.22.4
* glibc-2.11-r1
* qt-4.6.2
* gcc-4.4.3
* gentoo-sources-2.6.31-r5

Recompiling glib, glibc, qt didn't show any effect.

The patch is a nice workaround for the segfault, however this is just the tip of the ice-berg. Even for a simple dummy application like this...

#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    return 0;
}

...valgrind reveals a whole bunch of invalid reads/writes and unfreed memory errors. Actually I'm surprised that most Qt/KDE applications get away with it without crashing.

I don't have any such issues on my Kubuntu box in the office (same version of Qt but probably different versions for gcc, glibc,... -  I need to check tomorrow). So either this is a Gentoo-specific problem or a problem with another library or the kernel.
Comment 12 Markos Chandras (RETIRED) gentoo-dev 2010-05-10 17:38:44 UTC
ping, need to get this fixed ( by applying the patches, since upstream doesn't cooperate ), or push it for discussion in our next meeting
Comment 13 Markus Lohse 2010-05-10 18:44:52 UTC
Created attachment 230997 [details]
test application segfaulting with broken Qt lib

how to build:
$ qmake -project svgtest.cpp
$ echo QT += svg >> svgtest.pro
$ make
$ ./svgtest

This crashes with a broken Qt lib (Gentoo default), but works fine with custom build Qt lib (both 4.6.2)
Comment 14 Markus Lohse 2010-05-10 18:55:16 UTC
There must be something wrong with the modular way we build Qt on Gentoo. I took the Qt source from the distfiles directory, extracted and build it manually.

Result: The above mentioned test application works just fine with the custom build but crashes with the Gentoo build (on the same machine, same build environment, etc...)

I recommend to push it to the meeting. Perhaps someone comes up with a clean solution or has an idea where to start looking.

PS: A friend of mine also reproduced this bug on his amd64.
Comment 15 Davide Pesavento gentoo-dev 2010-05-10 19:46:33 UTC
(In reply to comment #12)
> ping, need to get this fixed ( by applying the patches, since upstream doesn't
> cooperate ), or push it for discussion in our next meeting
> 

I think we should discuss this issue at the next Qt meeting and try to find the root cause. Upstream rejected the patches so we shouldn't apply them.
Comment 16 Aleksandar Petrinic 2010-05-11 17:35:12 UTC
I did some tests and it seems the bug is related to our qt modularization.

I tried it on exherbo too but it works(both amd64, same gcc, glibc, cxxflags/ldflags, qt etc...; the same svgtest compiled on gentoo works fine in exherbo).
Pay attention it has a monolithic qt.

I kindly asked the sourcemagery guys about that bug and they can't reproduce it(sourcemagery has monolithic qt too).

Comment 17 Davide Pesavento gentoo-dev 2010-05-20 20:11:28 UTC
wired verified that this is caused by our modular qt-svg ebuild. We'll try to find the root cause. If the investigation won't be successful, qt-svg will be merged into qt-gui, controlled by a new 'svg' USE flag.
Comment 18 Aleksandar Petrinic 2010-05-22 04:04:29 UTC
This solution is not so bad as the final solution, the real problem is... there are a lot of packages that will need a rewrite in the tree. The push has to be done(ideally) at the same time as the packages updates... and probably for most of them (maybe we can avoid the ones which have only a blocker with qt-svg as they have already a block with qt-gui) it will need a revision bump. Let's hope to find the root cause(hopefully with the doable fix), but this bug is becoming more and more voodo stuff and I'm a bit discouraged about it.
Comment 19 Markos Chandras (RETIRED) gentoo-dev 2010-06-09 13:50:31 UTC
Need to make this a top priority for our next meeting. I would propose to gather up and try to figure what to in a separate session if needed.

http://tinderbox.dev.gentoo.org/misc/rindex/x11-libs/qt-svg

There are so many packages that depend on qt-svg so merging it with qt-gui should be the very last solution

I would proposed to start building Qt with gdb symbols support so we can look deeper on that

http://www.gentoo.org/proj/en/qa/backtraces.xml
Comment 20 Davide Pesavento gentoo-dev 2010-06-10 21:24:59 UTC
Unfortunately I can't reproduce the crash when I run the test case under valgrind :-(
Comment 21 Markus Lohse 2010-06-10 21:57:30 UTC
Yes, it doesn't crash in valgrind - yet you should see several invalid read/write errors.
However, running it in a debugger gives me this (received SIGABRT):
0	__kernel_vsyscall		0	0xb7fdf424	
1	raise	/lib/libc.so.6	0	0xb6d99f71	
2	abort	/lib/libc.so.6	0	0xb6d9b7b9	
3	??	/lib/libc.so.6	0	0xb6dd71a5	
4	??	/lib/libc.so.6	0	0xb6ddd86f	
5	??	/lib/libc.so.6	0	0xb6de08ac	
6	malloc	/lib/libc.so.6	0	0xb6de276c	
7	qMalloc(unsigned int)	/usr/lib/qt4/libQtCore.so.4	0	0xb718c2bb	
8	QHashData::allocateNode(int)	/usr/lib/qt4/libQtCore.so.4	0	0xb71b32e3	
9	QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>)	/usr/lib/qt4/libQtGui.so.4	0	0xb755548b	
10	QWidget::QWidget(QWidgetPrivate&, QWidget*, QFlags<Qt::WindowType>)	/usr/lib/qt4/libQtGui.so.4	0	0xb7555757	
11	QSvgWidget::QSvgWidget(QWidget*)	/usr/lib/qt4/libQtSvg.so.4	0	0xb7ea5aab	
12	main		0	0x080488a8	

I grepped for QT_NO_SVG in those files as this bug is obviously triggered by a configuration setting - but nothing :( I'm going to rebuild Qt with debug symbols this weekend... perhaps I find something then.
Comment 22 Davide Pesavento gentoo-dev 2010-06-10 22:28:53 UTC
WTF... you get the abort during object construction/allocation, while for me it's exactly the opposite: glibc complains about a double free and gdb shows a stack trace full of destructors...
Comment 23 Markus Lohse 2010-06-10 22:50:44 UTC
Hmm, yeah weird... I used to get a segmentation fault when reparenting the SvgWidget to any other Widget (either in the constructor or by calling setParent() later - doesn't matter). But now I even get the SIGABRT with the test application mentioned in #7 which worked fine for me a few weeks ago.


Comment 24 Fabio Rossi 2010-08-14 12:58:36 UTC
(In reply to comment #7)
> Upstream closed the bug report as "not a Qt bug". However I can consistently
> reproduce the crash with Qt 4.6.1, using the following reduced testcase:
> 
> #include <QApplication>
> #include <QSvgWidget>
> 
> int main(int argc, char *argv[])
> {
>         QApplication app(argc, argv);
>         QSvgWidget();
>         return 0;
> }
> 

Something is really weird also because the Makefile generated by qmake is not considering QSvg stuff (missing include path and lib). An exec which segfaults is created by setting manually the -I and -l parameters to INCPATH and LIBS respectively.
Comment 25 Davide Pesavento gentoo-dev 2010-08-14 14:19:42 UTC
(In reply to comment #24)
> (In reply to comment #7)
> > Upstream closed the bug report as "not a Qt bug". However I can consistently
> > reproduce the crash with Qt 4.6.1, using the following reduced testcase:
> > 
> > #include <QApplication>
> > #include <QSvgWidget>
> > 
> > int main(int argc, char *argv[])
> > {
> >         QApplication app(argc, argv);
> >         QSvgWidget();
> >         return 0;
> > }
> > 
> 
> Something is really weird also because the Makefile generated by qmake is not
> considering QSvg stuff (missing include path and lib). An exec which segfaults
> is created by setting manually the -I and -l parameters to INCPATH and LIBS
> respectively.
> 

Did you put 'QT += svg' inside the .pro file?
Comment 26 Fabio Rossi 2010-08-14 15:15:58 UTC
(In reply to comment #25)

> Did you put 'QT += svg' inside the .pro file?

Oops, my fault. I didn't know about that...
Comment 27 Fedor Sakharov 2010-11-19 11:52:06 UTC
The same with x11-libs/qt-svg-4.6.3 on my box. Any solutions yet?
Comment 28 Davide Pesavento gentoo-dev 2010-11-19 13:46:49 UTC
I can't reproduce any longer with qt 4.7.1, but valgrind still reports 1 invalid read and 2 invalid writes involving QSvgWidgetPrivate.

==7234== Invalid write of size 8
==7234==    at 0x52862A2: QWidgetPrivate::QWidgetPrivate(int) (qwidget.cpp:277)
==7234==    by 0x4E6BB19: QSvgWidget::QSvgWidget(QWidget*) (qsvgwidget.cpp:83)
==7234==    by 0x4009A2: main (in /tmp/svgcrash)
==7234==  Address 0xe7c9350 is 0 bytes after a block of size 496 alloc'd
==7234==    at 0x4C26B8E: operator new(unsigned long) (vg_replace_malloc.c:261)
==7234==    by 0x4E6BB09: QSvgWidget::QSvgWidget(QWidget*) (qsvgwidget.cpp:93)
==7234==    by 0x4009A2: main (in /tmp/svgcrash)
==7234== 
==7234== Invalid read of size 4
==7234==    at 0x52E78C8: QX11Info::~QX11Info() (qx11info_x11.cpp:104)
==7234==    by 0x52889CA: QWidgetPrivate::~QWidgetPrivate() (qwidget.cpp:323)
==7234==    by 0x4E6BD02: QSvgWidgetPrivate::~QSvgWidgetPrivate() (qsvgwidget.cpp:83)
==7234==    by 0x5E9DA2B: QObject::~QObject() (qscopedpointer.h:62)
==7234==    by 0x52965B9: QWidget::~QWidget() (qwidget.cpp:1620)
==7234==    by 0x4009AE: main (in /tmp/svgcrash)
==7234==  Address 0xe7c95f0 is 0 bytes inside a block of size 16 free'd
==7234==    at 0x4C2535F: operator delete(void*) (vg_replace_malloc.c:387)
==7234==    by 0x5E9631E: QObjectPrivate::deleteChildren() (qobject.cpp:1949)
==7234==    by 0x52964FA: QWidget::~QWidget() (qwidget.cpp:1600)
==7234==    by 0x4009AE: main (in /tmp/svgcrash)
==7234== 
==7234== Invalid write of size 4
==7234==    at 0x52E78CC: QX11Info::~QX11Info() (qx11info_x11.cpp:104)
==7234==    by 0x52889CA: QWidgetPrivate::~QWidgetPrivate() (qwidget.cpp:323)
==7234==    by 0x4E6BD02: QSvgWidgetPrivate::~QSvgWidgetPrivate() (qsvgwidget.cpp:83)
==7234==    by 0x5E9DA2B: QObject::~QObject() (qscopedpointer.h:62)
==7234==    by 0x52965B9: QWidget::~QWidget() (qwidget.cpp:1620)
==7234==    by 0x4009AE: main (in /tmp/svgcrash)
==7234==  Address 0xe7c95f0 is 0 bytes inside a block of size 16 free'd
==7234==    at 0x4C2535F: operator delete(void*) (vg_replace_malloc.c:387)
==7234==    by 0x5E9631E: QObjectPrivate::deleteChildren() (qobject.cpp:1949)
==7234==    by 0x52964FA: QWidget::~QWidget() (qwidget.cpp:1600)
==7234==    by 0x4009AE: main (in /tmp/svgcrash)
==7234== 
Comment 29 Aleksandar Petrinic 2010-11-25 20:00:49 UTC
Created attachment 255423 [details]
cave info qt-gui

Are you sure?
I'm on qt-4.7.1 too, but the bug is still present.
Can you paste some infos about your box ? I will put mine on attachment...
Comment 30 Jaak Ristioja 2010-12-13 14:09:48 UTC
I think that qt-svg also needs qt-gui[accessibility=] because of QWidgetPrivate.

My qt-gui was built with USE="accessibility", and hence I also got this bug. After modifying the qt-svg ebuild to use the same accessibility setting as qt-gui, things appear to work fine. So in the ebuild:

-IUSE="iconv"
+IUSE="accessibility iconv"
 
-DEPEND="~x11-libs/qt-gui-${PV}[aqua=,debug=]"
+DEPEND="~x11-libs/qt-gui-${PV}[accessibility=,aqua=,debug=]"

and substitute "-no-accessibility" with "$(qt_use accessibility)" in the "myconf" variable.
Comment 31 Jaak Ristioja 2010-12-13 14:14:02 UTC
Created attachment 257027 [details]
qt-svg-4.7.1.ebuild
Comment 32 Davide Pesavento gentoo-dev 2011-01-10 23:32:18 UTC
Created attachment 259512 [details, diff]
patch against qt-svg-4.7.1

Adds accessibility USE flag and removes a couple of redundant configure options from ${myconf}.
Comment 33 Theo Chatzimichos (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2011-01-15 14:51:38 UTC
patch in tree, thank you all for your contributions
Comment 34 Nikos Chantziaras 2011-01-16 00:36:46 UTC
(In reply to comment #33)
> patch in tree, thank you all for your contributions

You need "+accessibility" in IUSE to be consistent with the other qt ebuils.