Results 1 to 5 of 5

Thread: SIGSEGV during startup processing SLOT

  1. #1
    Join Date
    Jan 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SIGSEGV during startup processing SLOT

    I'm getting SIGSEGV during startup processing. I never reach the first line of my main. I have isolated this to an area of qobject.cpp near line 2537

    Qt Code:
    1. if (!check_method_code(membcode, receiver, method, "connect"))
    2. return false;
    3. const char *method_arg = method;
    4. ++method; // skip code
    5.  
    6. const QMetaObject *rmeta = receiver->metaObject();
    7. int method_index = -1;
    To copy to clipboard, switch view to plain text mode 
    The failure happens on the line containing "*remeta =" and I'm unable to trace into function metaObject. At the time, the metacode is processing my slot "catchLtiStart.

    Here is code from "moc_opolib.cpp" re catchLtiStart and others:
    Qt Code:
    1. int Opolib::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
    2. {
    3. _id = QObject::qt_metacall(_c, _id, _a);
    4. if (_id < 0)
    5. return _id;
    6. if (_c == QMetaObject::InvokeMetaMethod) {
    7. switch (_id) {
    8. case 0: lasLogin((*reinterpret_cast< QString(*)>(_a[1]))); break;
    9. case 1: lasSetParameters((*reinterpret_cast< const char*(*)>(_a[1]))); br
    10. case 2: lasSend((*reinterpret_cast< const char*(*)>(_a[1]))); break;
    11. case 3: lasSend((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret
    12. case 4: lasSend((*reinterpret_cast< QString(*)>(_a[1]))); break;
    13. case 5: lasLogout(); break;
    14. case 6: motLogin((*reinterpret_cast< QString(*)>(_a[1]))); break;
    15. case 7: motSetParameters((*reinterpret_cast< const char*(*)>(_a[1]))); br
    16. case 8: motSend((*reinterpret_cast< const char*(*)>(_a[1]))); break;
    17. case 9: motSend((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret
    18. case 10: motSend((*reinterpret_cast< QString(*)>(_a[1]))); break;
    19. case 11: motLogout(); break;
    20. case 12: lasError((*reinterpret_cast< QString(*)>(_a[1]))); break;
    21. case 13: motError((*reinterpret_cast< QString(*)>(_a[1]))); break;
    22. case 14: catchLtiStart(); break;
    23. case 15: catchMtiStart(); break;
    24. case 16: catchLasConnected(); break;
    25. case 17: catchLasError((*reinterpret_cast< QString(*)>(_a[1]))); break;
    26. case 18: catchLasNewMessage((*reinterpret_cast< QByteArray(*)>(_a[1])));
    27. case 19: catchLasTimedOut(); break;
    28. case 20: catchLthFinished(); break;
    29. case 21: catchMotConnected(); break;
    30. case 22: catchMotError((*reinterpret_cast< QString(*)>(_a[1]))); break;
    31. case 23: catchMotNewMessage((*reinterpret_cast< QByteArray(*)>(_a[1])));
    32. case 24: catchMotTimedOut(); break;
    33. case 25: catchMthFinished(); break;
    34. default: ;
    35. }
    36. _id -= 26;
    37. }
    38. return _id;
    39. }
    To copy to clipboard, switch view to plain text mode 
    And catchLtiStart is the first SLOT listed (I name SLOTs as catch*).

    SLOT catchLtiStart is not much:

    Qt Code:
    1. public slots:
    2. void catchLtiStart() {lti.start(TIMEOUT);} //start laser SerialClient breakout timer
    To copy to clipboard, switch view to plain text mode 

    I'm assuming this is memory corruption or, more likely, stack corruption but am at a loss as to where to look.

    Any hints?


    Added after 9 minutes:


    Oops, sorry about the code markup.

    Version info: Qt Creator 2.0.0 based on Qt 4.7.0 (32 bit) built Jun 21 2010 at 01:56:06 using MinGW compiler g++ 4.4.0 on Windows 7.
    Last edited by Lykurg; 24th January 2011 at 21:01.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SIGSEGV during startup processing SLOT

    Is this specific to only one project, or are you unable to compile and start any Qt program at your computer?

  3. #3
    Join Date
    Jan 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SIGSEGV during startup processing SLOT

    It's specific to this project; I have made a TCP/IP server previously using Qt and had no problems of this sort.


    Added after 9 minutes:


    Some further information:

    I have a class "Laser" and a main class "Opolib". Opolib has a Laser member. The problem is arising during construction of member class "Laser. Here is the constructor:

    Qt Code:
    1. Laser::Laser() : QObject(0), per(0)
    2. {
    3. connect(this, SIGNAL(ltiStart()), ol, SLOT(catchLtiStart())
    4. , Qt::QueuedConnection);
    5. thr = new QThreadExec;
    6. moveToThread(thr);
    7. thr->start();
    8. }
    To copy to clipboard, switch view to plain text mode 

    And here is the definition of class "Laser":
    Qt Code:
    1. class Laser : public QObject {
    2. Q_OBJECT
    3.  
    4. LasCmd cmd; //command to send or last sent
    5. int delay; //delay argument to Q-Switch
    6. Opolib *ol; //cross-reference
    7. int per; //percent of full power
    8. QByteArray qarr; //general purpose byte array
    9. QString qstr; //general purpose string
    10. QThreadExec *thr; //thread event loop for Laser object
    11.  
    12. public:
    13. Distrib dist; //persistent data for distributed processing
    14. double delayGain; //Q-Switch delay slope
    15. double minDelay; //Q-Switch delay for minimum laser power
    16.  
    17. //ctors
    18. Laser();
    19.  
    20. //accessors
    21. void setOpolib(Opolib *Ol) {ol = Ol;}
    22.  
    23. //methods
    24. void lasCommand(
    25. QByteArray &msg);
    26. int percent() {return per;}
    27.  
    28. signals:
    29. void lasError(QString);
    30. void lasFinis();
    31. void lasLogout();
    32. void lasSend(const char*);
    33. void lasSend(const char*, int);
    34. void lasSend(QString);
    35. void ltiStart();
    36.  
    37. public slots:
    38. void commandLas(LasCmd Cmd)
    39. {
    40. qa[0] = '\0';
    41. memset(&dist, '\0', sizeof(dist));
    42. cmd = Cmd;
    43. lasCommand(qa);
    44. }
    45. void setLasPower(int percent)
    46. {
    47. per = qBound(0, percent, 100);
    48. delay = int(minDelay + delayGain*per);
    49. commandLas(LasDelay);
    50. }
    51. };
    To copy to clipboard, switch view to plain text mode 


    Added after 6 minutes:


    Yee Hah! The Aha moment dawns.

    I think I see the problem. At the time that the Laser object is being constructed, the cross-reference pointer has not yet been set. Anybody concur?
    Last edited by deanz1; 24th January 2011 at 21:52.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SIGSEGV during startup processing SLOT

    Well it seems to me that in the c-tor ol is uninitialized! Try to do the connection in setOpolib().

    EDIT: Yes...

  5. #5
    Join Date
    Jan 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SIGSEGV during startup processing SLOT

    That was the problem.


    Thanks to all for the help and, in the spirit of Homer, Doh!

Similar Threads

  1. Sigsegv
    By babygal in forum Newbie
    Replies: 3
    Last Post: 2nd November 2010, 05:29
  2. QTextEdit SIGSEGV
    By Flayer in forum Qt Programming
    Replies: 4
    Last Post: 14th January 2010, 22:52
  3. sigsegv ?
    By mero in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 18:01
  4. QSqlQueryModel::setQuery - SIGSEGV
    By onamatic in forum Qt Programming
    Replies: 14
    Last Post: 27th January 2009, 10:26
  5. QAbstractSocket::abort() with SIGSEGV
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2008, 17:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.