PDA

View Full Version : !!!A Strange Crash



hhf
9th March 2010, 08:55
bad luck I forgot my qtcentre account,
these days I am stuck over a Qt problem , I tried whatsoever I can do and hence I surrendered.
my projects built successfully on Ubuntu , but when I ran it , it crashed at the very beginning.

here is the backtrace from gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x035364ff in XSetCommand () from /usr/lib/libX11.so.6
#2 0x0353af51 in XSetWMProperties () from /usr/lib/libX11.so.6
#3 0x0100f134 in QWidgetPrivate::create_sys (this=0x8313fb0, window=0,
initializeWindow=true, destroyOldWindow=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget_x11.cpp:795
#4 0x00fc7b21 in QWidget::create (this=0xbffff1cc, window=0, initializeWindow=true,
destroyOldWindow=true) at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:1319
#5 0x00fca7b1 in QWidget::setVisible (this=0xbffff1cc, visible=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:7353
#6 0x081c7e53 in main ()


I asked google for help and checked all the result items thoroughly,


Martin Sander added a comment - 28/Jan/10 04:42 PM
I got the same crash.
Suprisingly it is not only the argv causing the problem.
It's the "design" of QCoreApplication: it stores the argc as reference.
In the example in QappRun the argv AND argc have to be static.
Very nasty: if you subclass from QCoreApplication or QApplication and then forget the & in the subclass constructor.


[ Permalink | « Hide ]
Zeno Albisser added a comment - 08/Feb/10 03:29 PM
I wonder what exactly should be the use case of this implementation.
It of course crashes because argv is not valid anymore after leaving QappRun.
Further the documentation of QApplication mentions:
"Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string."

Qt Version? the two arguments ,argc? argv?
many people got the same crash , but there was no solution found ,
so . if you met the same problem before, be nice to give me tips, thank you...

high_flyer
9th March 2010, 09:11
1. post your main()
2. run in debugger and tell us which line in main() is crashing.

hhf
9th March 2010, 09:42
//I did not have right to expose the code , hence I replace some word that maybe make me in trouble with XXX.
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(xxx);
QCoreApplication::setOrganizationName("xxx System");
QCoreApplication::setOrganizationDomain("xxx.com");
QCoreApplication::setApplicationName("xxx Design");
QCoreApplication::setApplicationVersion("5.0.0");

int result = -1;

XXXInit::instance().nextStage();
XXXApplication app(argc, argv);
app.setLanguage();

XXXSplashScreen splash; //XXXSplashScreen encapsulate the QSplashScreen
splash.show(); //the program crash right here
app.setWindowIcon(QIcon());

XXXInit::instance().nextStage();

Initialisationer initer;

XXXMainWindow mainwindow;
mainwindow.show();

splash.finish(&mainwindow);

app.setMainWindow(&mainwindow);

XXXInit::instance().nextStage();
result = app.exec();

XXXInit::instance().nextStage();

return result;
}




Program received signal SIGSEGV, Segmentation fault.
0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0x00c59f93 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x035364ff in XSetCommand () from /usr/lib/libX11.so.6
#2 0x0353af51 in XSetWMProperties () from /usr/lib/libX11.so.6
#3 0x0100f134 in QWidgetPrivate::create_sys (this=0x8313fb0, window=0,
initializeWindow=true, destroyOldWindow=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget_x11.cpp:795
#4 0x00fc7b21 in QWidget::create (this=0xbffff1cc, window=0, initializeWindow=true,
destroyOldWindow=true) at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:1319
#5 0x00fca7b1 in QWidget::setVisible (this=0xbffff1cc, visible=true)
at /var/tmp/qt-src/src/gui/kernel/qwidget.cpp:7353
#6 0x081c7e53 in main ()


the job will not be done on time ... so depressing ........

high_flyer
9th March 2010, 09:47
it looks your are doing something wrong in the QSplashScreen wrapper...
If its not a lot of code, post it.

hhf
9th March 2010, 09:48
at a Qt internal function QWidgetPrivate::create_sys

XSetWMProperties(dpy, id, 0, 0,
qApp->d_func()->argv, qApp->d_func()->argc,
&size_hints, &wm_hints, &class_hint);

splash.show(); //the program crash right here

high_flyer
9th March 2010, 09:51
we cross posted... see my post before yours.

hhf
9th March 2010, 09:59
all the code can run perfectly on win32 platform , crazy me !



XXXSplashScreen::XXXSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)
: QSplashScreen(parent, pixmap, f)
{
setWindowOpacity(0.9);
}

XXXSplashScreen::XXXSplashScreen(QWidget *parent)
: QSplashScreen(parent, QPixmap(":/images/splashscreen.png"), Qt::WindowStaysOnTopHint)
{
setWindowOpacity(0.9);
}

void
XXXSplashScreen::drawContents(QPainter *painter)
{
int left = 180;
int top = 15;
int bottomLimit = 75;
int rightLimit = width();
QRect rect(left, top, rightLimit - left, bottomLimit - top);
QFont titleFont = QApplication::font();
titleFont.setBold(true);
titleFont.setPointSize(titleFont.pointSize() + 1);
painter->setFont(titleFont);
painter->drawText(rect, Qt::AlignLeft, app().fullName());
}

void
XXXSplashScreen::show()
{
QSplashScreen::show();
showMessage(QString());
}

more nasty , it run fine in debug mode , but get a 'Segmentation fault' in release mode.

high_flyer
9th March 2010, 11:22
it could be that due to configuration issues, your image is not found, and thus you get a null pixmap.
Try this:


XXXSplashScreen splash; //XXXSplashScreen encapsulate the QSplashScreen
if(splsh.pixmap().isNull()){
qDebug()<<"nuill pixmap";
}

splash.show(); //the program crash right here
app.setWindowIcon(QIcon());


and see if the debug message comes out, or you can set a break point on the debug message.

hhf
10th March 2010, 01:26
the debug message didn't come out, the image can be found..

hhf
10th March 2010, 02:26
since it crash only in release mode, breakpoints set in the code can not work.
how to make the program debug-able in release mode?

high_flyer
10th March 2010, 11:20
how to make the program debug-able in release mode?
you can put a debug message in all the methods at the beginning, and at the end, this way you will see which method started but didn't complete.
It will help narrow down where the problem is.

hhf
10th March 2010, 12:28
thank you so much .
boss passed this job back to the author already .
but now I face to a bigger challenge, a man came back to Canada, leaving a 'mess' for me, he use french to name all the variables ,macros and things like that ...I don't know french at all, the code seem unfriendly to me, nightmare

high_flyer
10th March 2010, 12:45
Well, that is not something I can help you with, I am afraid...