[Linux] Some problems with arguments...
-
I can generate executable which crashes after ./test, but if I set three arguments or more (for instance ./test 1 2 3) the program will not crash.
You can find code in https://github.com/Kakadu/lablqt/tree/master/simple_signals repository. To compile it you should have installed ocaml compiler. Try git://github.com/Kakadu/lablqt.git && cd lablqt/simple_signals && make && cd test && make && ./test.
I've understand that problem is in line 794 in src/gui/kernel/qwidget_x11.cpp in Qt sources
@ XSetWMProperties(dpy, id, 0, 0,
qApp->d_func()->argv, qApp->d_func()->argc,
&size;_hints, &wm;_hints, &class;_hint);@Here I have argc = 5, argv[0] is path to executable file (in case of calling ./test without parameters), argv[1]=argv[2] usually is 0, and accessing to argv[3] sends SIGSEGV.
But in constructor @QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p)@
everything is OK and argc==1.I think that there is a bug in Qt sources. Does anybody can explain how classes QCoreApplicationPrivate and QCoreApplication are connected and what is hidden in line
qApp->d_func()->argc
? -
d_func() is part of Qt's Pimpl implementation, a technique to reduce compile times and to keep binary compatibility.
In general I have the impression that you are digging too deep. Passing a couple of arguments with Qt was done a million times before. There are many reasons why things behave the way you described. Does your program do different things based on the given arguments? If not it rather looks like a pointer is accessing garbage.
-
My program should do the same with any arguments list.
http://www.youtube.com/watch?v=O4an9pp_VPs
I've created a little creencast with my attempts of debugging. Maybe it will be useful.