Qt-interest Archive, June 2007
segmentation fault with a really simple code snippet
Message 1 in thread
Hi all,
by now I have spent many hours debugging and looking for what causes
a segmentation fault in my app. Simplifying the code I ended up with
just these lines of code:
#include <iostream>
#include <QApplication>
class MyApplication : public QApplication
{
public:
MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
};
int main(int argc, char **argv)
{
std::cout << "Creating application" << std::endl;
MyApplication app(argc, argv);
std::cout << "Entering event loop..." << std::endl;
return app.exec();
}
which cause a segfault on my system.
debian testing
gcc 4.1.1
Qt 4.2.2
Am I doing something wrong? I'll appreciate any help, cause
I am kind of lost now.
Tomas
--
[ signature omitted ]
Message 2 in thread
Your class definition is missing the Q_OBJECT macro. Perhaps that's it?
Tomáš Kazmar wrote:
> Hi all,
>
> by now I have spent many hours debugging and looking for what causes
> a segmentation fault in my app. Simplifying the code I ended up with
> just these lines of code:
>
> #include <iostream>
> #include <QApplication>
>
> class MyApplication : public QApplication
> {
> public:
> MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
> };
>
> int main(int argc, char **argv)
> {
> std::cout << "Creating application" << std::endl;
> MyApplication app(argc, argv);
> std::cout << "Entering event loop..." << std::endl;
> return app.exec();
> }
>
> which cause a segfault on my system.
>
> debian testing
> gcc 4.1.1
> Qt 4.2.2
>
> Am I doing something wrong? I'll appreciate any help, cause
> I am kind of lost now.
>
>
> Tomas
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
---
This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.
Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.
--
[ signature omitted ]
Message 3 in thread
# Your class definition is missing the Q_OBJECT macro. Perhaps that's it?
That's not it. It was in the original code and if I split the code into a header
and source and add the macro, segfault is still there.
But still, thanks for your reply.
# Tomáš Kazmar wrote:
# > Hi all,
# >
# > by now I have spent many hours debugging and looking for what causes
# > a segmentation fault in my app. Simplifying the code I ended up with
# > just these lines of code:
# >
# > #include <iostream>
# > #include <QApplication>
# >
# > class MyApplication : public QApplication
# > {
# > public:
# > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
# > };
# >
# > int main(int argc, char **argv)
# > {
# > std::cout << "Creating application" << std::endl;
# > MyApplication app(argc, argv);
# > std::cout << "Entering event loop..." << std::endl;
# > return app.exec();
# > }
# >
# > which cause a segfault on my system.
# >
# > debian testing
# > gcc 4.1.1
# > Qt 4.2.2
# >
# > Am I doing something wrong? I'll appreciate any help, cause
# > I am kind of lost now.
# >
# >
# > Tomas
# >
# > --
# > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# "unsubscribe" in the subject or the body.
# > List archive and information: http://lists.trolltech.com/qt-interest/
# >
# >
# >
#
#
#
# ---
#
# This communication contains confidential information. If you are not the
# intended recipient please return this email to the sender and delete it from
# your records.
#
# Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der
# beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den
# Absender zurück und löschen Sie die E-mail aus Ihrem System.
#
# --
# To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# "unsubscribe" in the subject or the body.
# List archive and information: http://lists.trolltech.com/qt-interest/
#
#
#
#
--
[ signature omitted ]
Message 4 in thread
Which line is it crashing on... As an aside my QT 4.2.3 on Windows XP works as expected.. no crash
Scott
> -----Original Message-----
> From: Tomáš Kazmar [mailto:Tomash.Kazmar@xxxxxxxxx]
> Sent: Thursday, June 07, 2007 12:58 PM
> To: Susan Macchia
> Cc: qt-interest@xxxxxxxxxxxxx
> Subject: Re: segmentation fault with a really simple code snippet
>
> # Your class definition is missing the Q_OBJECT macro. Perhaps that's it?
> That's not it. It was in the original code and if I split the code into a
> header
> and source and add the macro, segfault is still there.
>
> But still, thanks for your reply.
>
> # Tomáš Kazmar wrote:
> # > Hi all,
> # >
> # > by now I have spent many hours debugging and looking for what causes
> # > a segmentation fault in my app. Simplifying the code I ended up with
> # > just these lines of code:
> # >
> # > #include <iostream>
> # > #include <QApplication>
> # >
> # > class MyApplication : public QApplication
> # > {
> # > public:
> # > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
> # > };
> # >
> # > int main(int argc, char **argv)
> # > {
> # > std::cout << "Creating application" << std::endl;
> # > MyApplication app(argc, argv);
> # > std::cout << "Entering event loop..." << std::endl;
> # > return app.exec();
> # > }
> # >
> # > which cause a segfault on my system.
> # >
> # > debian testing
> # > gcc 4.1.1
> # > Qt 4.2.2
> # >
> # > Am I doing something wrong? I'll appreciate any help, cause
> # > I am kind of lost now.
> # >
> # >
> # > Tomas
> # >
> # > --
> # > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> # "unsubscribe" in the subject or the body.
> # > List archive and information: http://lists.trolltech.com/qt-interest/
> # >
> # >
> # >
> #
> #
> #
> # ---
> #
> # This communication contains confidential information. If you are not the
> # intended recipient please return this email to the sender and delete it
> from
> # your records.
> #
> # Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht
> der
> # beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an
> den
> # Absender zurück und löschen Sie die E-mail aus Ihrem System.
> #
> # --
> # To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> # "unsubscribe" in the subject or the body.
> # List archive and information: http://lists.trolltech.com/qt-interest/
> #
> #
> #
> #
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 5 in thread
It doesn't crash on my Qt 4.2.3, gcc 4.1.2, Gentoo Linux either. Maybe
there's something wrong with your setup?
Have you tried debugging it by running through gdb or similar debugger?
Maybe that would tell you where it is seg-faulting.
Matt
Scott Aron Bloom wrote:
> Which line is it crashing on... As an aside my QT 4.2.3 on Windows XP works as expected.. no crash
>
> Scott
>
>
>> -----Original Message-----
>> From: Tomáš Kazmar [mailto:Tomash.Kazmar@xxxxxxxxx]
>> Sent: Thursday, June 07, 2007 12:58 PM
>> To: Susan Macchia
>> Cc: qt-interest@xxxxxxxxxxxxx
>> Subject: Re: segmentation fault with a really simple code snippet
>>
>> # Your class definition is missing the Q_OBJECT macro. Perhaps that's it?
>> That's not it. It was in the original code and if I split the code into a
>> header
>> and source and add the macro, segfault is still there.
>>
>> But still, thanks for your reply.
>>
>> # Tomáš Kazmar wrote:
>> # > Hi all,
>> # >
>> # > by now I have spent many hours debugging and looking for what causes
>> # > a segmentation fault in my app. Simplifying the code I ended up with
>> # > just these lines of code:
>> # >
>> # > #include <iostream>
>> # > #include <QApplication>
>> # >
>> # > class MyApplication : public QApplication
>> # > {
>> # > public:
>> # > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
>> # > };
>> # >
>> # > int main(int argc, char **argv)
>> # > {
>> # > std::cout << "Creating application" << std::endl;
>> # > MyApplication app(argc, argv);
>> # > std::cout << "Entering event loop..." << std::endl;
>> # > return app.exec();
>> # > }
>> # >
>> # > which cause a segfault on my system.
>> # >
>> # > debian testing
>> # > gcc 4.1.1
>> # > Qt 4.2.2
>> # >
>> # > Am I doing something wrong? I'll appreciate any help, cause
>> # > I am kind of lost now.
>> # >
>> # >
>> # > Tomas
>> # >
>> # > --
>> # > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> # "unsubscribe" in the subject or the body.
>> # > List archive and information: http://lists.trolltech.com/qt-interest/
>> # >
>> # >
>> # >
>> #
>> #
>> #
>> # ---
>> #
>> # This communication contains confidential information. If you are not the
>> # intended recipient please return this email to the sender and delete it
>> from
>> # your records.
>> #
>> # Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht
>> der
>> # beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an
>> den
>> # Absender zurück und löschen Sie die E-mail aus Ihrem System.
>> #
>> # --
>> # To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> # "unsubscribe" in the subject or the body.
>> # List archive and information: http://lists.trolltech.com/qt-interest/
>> #
>> #
>> #
>> #
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]
Message 6 in thread
# Which line is it crashing on... As an aside my QT 4.2.3 on Windows XP works as
# expected.. no crash
It crashes in the event loop, this is the backtrace:
Creating application
Entering event loop...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223080240 (LWP 29762)]
0xb7e75d1d in QString::fromLocal8Bit () from /usr/lib/libQtCore.so.4
(gdb) bt
#0 0xb7e75d1d in QString::fromLocal8Bit () from /usr/lib/libQtCore.so.4
#1 0xb7eebc01 in QCoreApplication::arguments () from /usr/lib/libQtCore.so.4
#2 0xb787a4e1 in QApplicationPrivate::x11_initialize_style () from /usr/lib/libQtGui.so.4
#3 0xb787aff2 in QApplicationPrivate::x11_initialize_style () from /usr/lib/libQtGui.so.4
#4 0xb7361e8d in _SmcProcessMessage () from /usr/lib/libSM.so.6
#5 0xb73544e8 in IceProcessMessages () from /usr/lib/libICE.so.6
#6 0xb7874f54 in QApplicationPrivate::appName () from /usr/lib/libQtGui.so.4
#7 0xb7874fcf in QApplicationPrivate::appName () from /usr/lib/libQtGui.so.4
#8 0xb7efaf55 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#9 0xb7efb8bc in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#10 0xb7f1a931 in QSocketNotifier::activated () from /usr/lib/libQtCore.so.4
#11 0xb7f021ef in QSocketNotifier::event () from /usr/lib/libQtCore.so.4
#12 0xb782766f in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#13 0xb7829e52 in QApplication::notify () from /usr/lib/libQtGui.so.4
#14 0xb7f0ce2d in QEventDispatcherGlib::hasPendingEvents () from /usr/lib/libQtCore.so.4
#15 0xb7433952 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#16 0xb743691f in g_main_context_check () from /usr/lib/libglib-2.0.so.0
#17 0xb7436e85 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#18 0xb7f0d362 in QEventDispatcherGlib::processEvents () from /usr/lib/libQtCore.so.4
#19 0xb78a5125 in QX11Info::copyX11Data () from /usr/lib/libQtGui.so.4
#20 0xb7ee8c31 in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#21 0xb7ee8d3a in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#22 0xb7eeb116 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#23 0xb78270e7 in QApplication::exec () from /usr/lib/libQtGui.so.4
#24 0x0804918f in main (argc=1, argv=0xbff78fa4) at /home/baf/tks/xaq/pok/main.cxx:15
# > -----Original Message-----
# > From: Tomáš Kazmar [mailto:Tomash.Kazmar@xxxxxxxxx]
# > Sent: Thursday, June 07, 2007 12:58 PM
# > To: Susan Macchia
# > Cc: qt-interest@xxxxxxxxxxxxx
# > Subject: Re: segmentation fault with a really simple code snippet
# >
# > # Your class definition is missing the Q_OBJECT macro. Perhaps that's it?
# > That's not it. It was in the original code and if I split the code into a
# > header
# > and source and add the macro, segfault is still there.
# >
# > But still, thanks for your reply.
# >
# > # Tomáš Kazmar wrote:
# > # > Hi all,
# > # >
# > # > by now I have spent many hours debugging and looking for what causes
# > # > a segmentation fault in my app. Simplifying the code I ended up with
# > # > just these lines of code:
# > # >
# > # > #include <iostream>
# > # > #include <QApplication>
# > # >
# > # > class MyApplication : public QApplication
# > # > {
# > # > public:
# > # > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
# > # > };
# > # >
# > # > int main(int argc, char **argv)
# > # > {
# > # > std::cout << "Creating application" << std::endl;
# > # > MyApplication app(argc, argv);
# > # > std::cout << "Entering event loop..." << std::endl;
# > # > return app.exec();
# > # > }
# > # >
# > # > which cause a segfault on my system.
# > # >
# > # > debian testing
# > # > gcc 4.1.1
# > # > Qt 4.2.2
# > # >
# > # > Am I doing something wrong? I'll appreciate any help, cause
# > # > I am kind of lost now.
# > # >
# > # >
# > # > Tomas
# > # >
# > # > --
# > # > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# > # "unsubscribe" in the subject or the body.
# > # > List archive and information: http://lists.trolltech.com/qt-interest/
# > # >
# > # >
# > # >
# > #
# > #
# > #
# > # ---
# > #
# > # This communication contains confidential information. If you are not the
# > # intended recipient please return this email to the sender and delete it
# > from
# > # your records.
# > #
# > # Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht
# > der
# > # beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an
# > den
# > # Absender zurück und löschen Sie die E-mail aus Ihrem System.
# > #
# > # --
# > # To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# > # "unsubscribe" in the subject or the body.
# > # List archive and information: http://lists.trolltech.com/qt-interest/
# > #
# > #
# > #
# > #
# >
# > --
# > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# > "unsubscribe" in the subject or the body.
# > List archive and information: http://lists.trolltech.com/qt-interest/
#
# --
# To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# "unsubscribe" in the subject or the body.
# List archive and information: http://lists.trolltech.com/qt-interest/
#
#
#
#
--
[ signature omitted ]
Message 7 in thread
Change your class to
class MyApplication : public QApplication
{
public:
MyApplication(int& argc, char **argv) : QApplication(argc, argv) {}
};
Notice the extra ampersand before argc. QApplication docs say argc and argv
must live as long as QApplication. I hit this a couple weeks ago was not
impressed.
Clint
On Thursday 07 June 2007 1:52:10 pm TomÃÅ Kazmar wrote:
> Hi all,
>
> by now I have spent many hours debugging and looking for what causes
> a segmentation fault in my app. Simplifying the code I ended up with
> just these lines of code:
>
> #include <iostream>
> #include <QApplication>
>
> class MyApplication : public QApplication
> {
> public:
> MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
> };
>
> int main(int argc, char **argv)
> {
> std::cout << "Creating application" << std::endl;
> MyApplication app(argc, argv);
> std::cout << "Entering event loop..." << std::endl;
> return app.exec();
> }
>
> which cause a segfault on my system.
>
> debian testing
> gcc 4.1.1
> Qt 4.2.2
>
> Am I doing something wrong? I'll appreciate any help, cause
> I am kind of lost now.
>
>
> Tomas
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 8 in thread
That's it, thanks to you all. Did not hope for that quick feedback:)
# Change your class to
# class MyApplication : public QApplication
# {
# public:
# MyApplication(int& argc, char **argv) : QApplication(argc, argv) {}
# };
#
# Notice the extra ampersand before argc. QApplication docs say argc and argv
# must live as long as QApplication. I hit this a couple weeks ago was not
# impressed.
#
# Clint
#
# On Thursday 07 June 2007 1:52:10 pm Tomáš Kazmar wrote:
# > Hi all,
# >
# > by now I have spent many hours debugging and looking for what causes
# > a segmentation fault in my app. Simplifying the code I ended up with
# > just these lines of code:
# >
# > #include <iostream>
# > #include <QApplication>
# >
# > class MyApplication : public QApplication
# > {
# > public:
# > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
# > };
# >
# > int main(int argc, char **argv)
# > {
# > std::cout << "Creating application" << std::endl;
# > MyApplication app(argc, argv);
# > std::cout << "Entering event loop..." << std::endl;
# > return app.exec();
# > }
# >
# > which cause a segfault on my system.
# >
# > debian testing
# > gcc 4.1.1
# > Qt 4.2.2
# >
# > Am I doing something wrong? I'll appreciate any help, cause
# > I am kind of lost now.
# >
# >
# > Tomas
# >
# > --
# > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# > "unsubscribe" in the subject or the body. List archive and information:
# > http://lists.trolltech.com/qt-interest/
#
#
# --
# To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
# "unsubscribe" in the subject or the body.
# List archive and information: http://lists.trolltech.com/qt-interest/
#
#
#
#
--
[ signature omitted ]
Message 9 in thread
For those that couldn't reproduce it, maybe you can if you insert
QStringList args = app.arguments();
after the
MyApplication app(argc, argv);
Would be nice to see Qt a bit more robust with argc/argv.
Clint
On Thursday 07 June 2007 2:09:35 pm Tomáš Kazmar wrote:
> That's it, thanks to you all. Did not hope for that quick feedback:)
>
> # Change your class to
> # class MyApplication : public QApplication
> # {
> # public:
> # MyApplication(int& argc, char **argv) : QApplication(argc, argv) {}
> # };
> #
> # Notice the extra ampersand before argc. QApplication docs say argc and
> argv # must live as long as QApplication. I hit this a couple weeks ago
> was not # impressed.
> #
> # Clint
> #
> # On Thursday 07 June 2007 1:52:10 pm Tomáš Kazmar wrote:
> # > Hi all,
> # >
> # > by now I have spent many hours debugging and looking for what causes
> # > a segmentation fault in my app. Simplifying the code I ended up with
> # > just these lines of code:
> # >
> # > #include <iostream>
> # > #include <QApplication>
> # >
> # > class MyApplication : public QApplication
> # > {
> # > public:
> # > MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
> # > };
> # >
> # > int main(int argc, char **argv)
> # > {
> # > std::cout << "Creating application" << std::endl;
> # > MyApplication app(argc, argv);
> # > std::cout << "Entering event loop..." << std::endl;
> # > return app.exec();
> # > }
> # >
> # > which cause a segfault on my system.
> # >
> # > debian testing
> # > gcc 4.1.1
> # > Qt 4.2.2
> # >
> # > Am I doing something wrong? I'll appreciate any help, cause
> # > I am kind of lost now.
> # >
> # >
> # > Tomas
> # >
> # > --
> # > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> # > "unsubscribe" in the subject or the body. List archive and information:
> # > http://lists.trolltech.com/qt-interest/
> #
> #
> # --
> # To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> # "unsubscribe" in the subject or the body.
> # List archive and information: http://lists.trolltech.com/qt-interest/
> #
> #
> #
> #
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 10 in thread
\
> For those that couldn't reproduce it, maybe you can if you insert
> QStringList args = app.arguments();
> after the
> MyApplication app(argc, argv);
>
> Would be nice to see Qt a bit more robust with argc/argv.
>
> Clint
Still no crash... but the QApplication constructor is clearly int & argc
Never notice it before... Of course I don't overload QApplication that
often.
Scott
--
[ signature omitted ]
Message 11 in thread
On Jun 7, 2007, at 3:52 PM, Tomáš Kazmar wrote:
> by now I have spent many hours debugging and looking for what causes
> a segmentation fault in my app. Simplifying the code I ended up with
> just these lines of code:
>
> class MyApplication : public QApplication
> {
> public:
> MyApplication(int argc, char **argv) : QApplication(argc, argv) {}
> };
Try
MyApplication( int& argc, char** argv ) : QApplication( argc,
argv ) {}
Note the ampersand.
Brad
--
[ signature omitted ]