Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. segmentation fault
Forum Updated to NodeBB v4.3 + New Features

segmentation fault

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt 4.8cross-compilingarmv7mqtt
61 Posts 6 Posters 25.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Milav
    wrote on 12 Oct 2019, 10:31 last edited by
    #1

    Hello,

    I make a qt application for Embedded Custom Board and when i run the Application it gives segmentation fault.

    The application give segmentation fault due to following line.

      mosq->subscribe(mosq->getMID(), topic.data(), 1);
    

    where mosq is define and declare as follow.

    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        qtmosq* mosq = NULL;
        QStringList subed;
        QString currentTopic;
        Ui::MainWindow *ui;
    --------
    --------
    --------
    };
    

    where qtmosq is define as follow..

    #include "QObject"
    #include "mosquittopp.h"
    
    using namespace mosqpp;
    
    class qtmosq : public QObject, public mosquittopp
    {
        Q_OBJECT
    
    public:
        qtmosq(const char *id = NULL, bool clean_session = true) : mosquittopp (id, clean_session) {MID = 0;}
        ~qtmosq() {}
    
        void on_connect(int result)
        {
            if (!result)
            {
                //subscribe(NULL, "$SYS/#", 2);
                emit connected();
            }
            else
                emit connectEnable();
        }
        void on_publish(int id)
        {
            MID++;
            emit messageSent(true);
        }
        void on_subscribe(int mid, int qos_count, const int *granted_qos)
        {
            if (MID != 0)
                emit subscribed();
            MID++;
        }
    ..........
    ..........
    ..........
    
    signals:
        void connected();
        void messageSent(bool);
        void messageReceived(QString);
        void connectEnable();
        void subscribed();
    };
    

    so what is the reason behind for this fault.

    The same application are successfully run on Host Linux PC.

    I have use same mosquitto library in both the test.

    please help me to sort out this problem.

    I have send the reference link at where i used above program.

    Link :- Ref. Link

    Thank you
    Milav Soni

    J P 2 Replies Last reply 12 Oct 2019, 10:48
    0
    • M Milav
      12 Oct 2019, 10:31

      Hello,

      I make a qt application for Embedded Custom Board and when i run the Application it gives segmentation fault.

      The application give segmentation fault due to following line.

        mosq->subscribe(mosq->getMID(), topic.data(), 1);
      

      where mosq is define and declare as follow.

      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      private:
          qtmosq* mosq = NULL;
          QStringList subed;
          QString currentTopic;
          Ui::MainWindow *ui;
      --------
      --------
      --------
      };
      

      where qtmosq is define as follow..

      #include "QObject"
      #include "mosquittopp.h"
      
      using namespace mosqpp;
      
      class qtmosq : public QObject, public mosquittopp
      {
          Q_OBJECT
      
      public:
          qtmosq(const char *id = NULL, bool clean_session = true) : mosquittopp (id, clean_session) {MID = 0;}
          ~qtmosq() {}
      
          void on_connect(int result)
          {
              if (!result)
              {
                  //subscribe(NULL, "$SYS/#", 2);
                  emit connected();
              }
              else
                  emit connectEnable();
          }
          void on_publish(int id)
          {
              MID++;
              emit messageSent(true);
          }
          void on_subscribe(int mid, int qos_count, const int *granted_qos)
          {
              if (MID != 0)
                  emit subscribed();
              MID++;
          }
      ..........
      ..........
      ..........
      
      signals:
          void connected();
          void messageSent(bool);
          void messageReceived(QString);
          void connectEnable();
          void subscribed();
      };
      

      so what is the reason behind for this fault.

      The same application are successfully run on Host Linux PC.

      I have use same mosquitto library in both the test.

      please help me to sort out this problem.

      I have send the reference link at where i used above program.

      Link :- Ref. Link

      Thank you
      Milav Soni

      J Offline
      J Offline
      JonB
      wrote on 12 Oct 2019, 10:48 last edited by
      #2

      @Milav said in segmentation fault:

      The application give segmentation fault due to following line.
      mosq->subscribe(mosq->getMID(), topic.data(), 1);

      Little information in your post. But likely one of:

      • mosq is nullptr/bad pointer
      • mosq->subscribe() or mosq->getMID() are raising the SEGV
      • topic.data() is raising SEGV

      You're using some external library code here, so who knows what that might do.
      Can't you run under debugger and get more specific traceback for the SEGV?

      M 1 Reply Last reply 12 Oct 2019, 11:24
      0
      • J JonB
        12 Oct 2019, 10:48

        @Milav said in segmentation fault:

        The application give segmentation fault due to following line.
        mosq->subscribe(mosq->getMID(), topic.data(), 1);

        Little information in your post. But likely one of:

        • mosq is nullptr/bad pointer
        • mosq->subscribe() or mosq->getMID() are raising the SEGV
        • topic.data() is raising SEGV

        You're using some external library code here, so who knows what that might do.
        Can't you run under debugger and get more specific traceback for the SEGV?

        M Offline
        M Offline
        Milav
        wrote on 12 Oct 2019, 11:24 last edited by
        #3

        @JonB said in segmentation fault:

        nullptr

        Thank you for your response.

        Debugger is not run, it gives following error.

        The inferior stopped because it received a signal from the Operating System.
        
        Signal name : SIGILL
        Signal meaning : Illegal instruction
        
        

        And i replace NULL value in mosq->getMID() ,
        i replace Topic Name direct instead of topic.data()

        but i face same problem.

        so may be it can be happen by

        1. mosq
        2. mosq->subscribe()

        so, is there any another way to solve this error.

        you tell me mosq is bad pointer, so what is best way to make it good pointer.

        is i used memory allocation in mosq defination?

        please help me to find out this error solution.

        Thank you
        MilaV Soni

        J 1 Reply Last reply 14 Oct 2019, 05:17
        0
        • M Milav
          12 Oct 2019, 11:24

          @JonB said in segmentation fault:

          nullptr

          Thank you for your response.

          Debugger is not run, it gives following error.

          The inferior stopped because it received a signal from the Operating System.
          
          Signal name : SIGILL
          Signal meaning : Illegal instruction
          
          

          And i replace NULL value in mosq->getMID() ,
          i replace Topic Name direct instead of topic.data()

          but i face same problem.

          so may be it can be happen by

          1. mosq
          2. mosq->subscribe()

          so, is there any another way to solve this error.

          you tell me mosq is bad pointer, so what is best way to make it good pointer.

          is i used memory allocation in mosq defination?

          please help me to find out this error solution.

          Thank you
          MilaV Soni

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 14 Oct 2019, 05:17 last edited by
          #4

          @Milav said in segmentation fault:

          you tell me mosq is bad pointer, so what is best way to make it good pointer.

          Create an instance and assign the pointer:

          mosq = new qtmosq();
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 15 Oct 2019, 04:34
          2
          • J jsulm
            14 Oct 2019, 05:17

            @Milav said in segmentation fault:

            you tell me mosq is bad pointer, so what is best way to make it good pointer.

            Create an instance and assign the pointer:

            mosq = new qtmosq();
            
            M Offline
            M Offline
            Milav
            wrote on 15 Oct 2019, 04:34 last edited by
            #5

            @jsulm

            i tried with above syntax.

            qtmosq* mosq;
             mosq = new qtmosq(id, true);
            

            but still i am face same segmentation fault error.

            can you please give me best solution for the same.

            J 1 Reply Last reply 15 Oct 2019, 04:36
            0
            • M Milav
              15 Oct 2019, 04:34

              @jsulm

              i tried with above syntax.

              qtmosq* mosq;
               mosq = new qtmosq(id, true);
              

              but still i am face same segmentation fault error.

              can you please give me best solution for the same.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 15 Oct 2019, 04:36 last edited by
              #6

              @Milav said in segmentation fault:

              but still i am face same segmentation fault error.

              Yes, because you now create a new local variable called mosq which is completely unrelated to mosq in MainWindow! So, the one in MainWindow remains a NULL pointer.
              Remove

              qtmosq* mosq;
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply 15 Oct 2019, 04:44
              1
              • J jsulm
                15 Oct 2019, 04:36

                @Milav said in segmentation fault:

                but still i am face same segmentation fault error.

                Yes, because you now create a new local variable called mosq which is completely unrelated to mosq in MainWindow! So, the one in MainWindow remains a NULL pointer.
                Remove

                qtmosq* mosq;
                
                M Offline
                M Offline
                Milav
                wrote on 15 Oct 2019, 04:44 last edited by
                #7

                @jsulm

                But than it give error like

                /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:47: error: 'mosq' was not declared in this scope
                

                Can i declare any another place like mainwindow.h?
                i also tried in mainwindow.h

                like following...

                private:
                    qtmosq* mosq;
                    QStringList subed;
                    QString currentTopic;
                    Ui::MainWindow *ui;
                
                

                but it gives same error.

                J 1 Reply Last reply 15 Oct 2019, 04:46
                0
                • M Milav
                  15 Oct 2019, 04:44

                  @jsulm

                  But than it give error like

                  /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:47: error: 'mosq' was not declared in this scope
                  

                  Can i declare any another place like mainwindow.h?
                  i also tried in mainwindow.h

                  like following...

                  private:
                      qtmosq* mosq;
                      QStringList subed;
                      QString currentTopic;
                      Ui::MainWindow *ui;
                  
                  

                  but it gives same error.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 15 Oct 2019, 04:46 last edited by jsulm
                  #8

                  @Milav Please show where exactly you're calling

                  mosq = new qtmosq();
                  

                  It must be inside one of the MainWindow methods.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  M 1 Reply Last reply 15 Oct 2019, 04:53
                  0
                  • J jsulm
                    15 Oct 2019, 04:46

                    @Milav Please show where exactly you're calling

                    mosq = new qtmosq();
                    

                    It must be inside one of the MainWindow methods.

                    M Offline
                    M Offline
                    Milav
                    wrote on 15 Oct 2019, 04:53 last edited by
                    #9

                    @jsulm

                    i call it in mainwindow.cpp file.

                    here i have send the code snip for that portion.

                    mainwindow.cpp

                    MainWindow::MainWindow(QWidget *parent) :
                        QMainWindow(parent),
                        ui(new Ui::MainWindow)
                    {
                        ui->setupUi(this);
                        ui->send->setDisabled(true);
                        ui->message->setDisabled(true);
                        ui->subscribe->setDisabled(true);
                        ui->topic->setDisabled(true);
                    
                        ui->lineIP->setText(QString("a3jkuztr3frwt4-ats.iot.ap-south-1.amazonaws.com"));
                        ui->linePort->setText(QString("8883"));
                    
                        lib_init();
                    
                        connect (ui->connect, SIGNAL(clicked()), this, SLOT(connectPressed()));
                        connect (ui->send, SIGNAL(clicked()), this, SLOT(sendPressed()));
                        connect (ui->subscribe, SIGNAL(clicked()), this, SLOT(subscribePressed()));
                    }
                    
                    void MainWindow::connectPressed()
                    {
                        QByteArray host = ui->lineIP->text().toLocal8Bit();
                        QByteArray id = ui->lineID->text().toLocal8Bit();
                    
                        int port = 0;
                        port = ui->linePort->text().toInt();
                        if (!port)
                        {
                            ui->linePort->clear();
                            return ;
                        }
                        ui->connect->setDisabled(true);
                    
                    
                        mosq = new qtmosq(id, true);
                        int size = sizeof(*mosq);
                        qDebug() << size;
                        connect (mosq, SIGNAL(connectEnable()), this, SLOT(connectEnabled()));
                        connect (mosq, SIGNAL(subscribed()), this ,SLOT(subscribed()));
                        connect (mosq, SIGNAL(connected()), this, SLOT(connected()));
                        connect (mosq, SIGNAL(messageSent(bool)), this, SLOT(setMessageStatus(bool)));
                        connect (mosq, SIGNAL(messageReceived(QString)), this, SLOT(showMessage(QString)));
                        mosq->connect_async(host.data(), port);
                        mosq->loop_start();
                    
                    }
                    

                    mainwindow.h

                    #include <QMainWindow>
                    #include "qtmosq.h"
                    
                    namespace Ui {
                    class MainWindow;
                    }
                    
                    class MainWindow : public QMainWindow
                    {
                        Q_OBJECT
                    
                    public:
                        explicit MainWindow(QWidget *parent = 0);
                        ~MainWindow();
                    
                    private:
                        qtmosq* mosq;
                        QStringList subed;
                        QString currentTopic;
                        Ui::MainWindow *ui;
                    
                    private slots:
                        void setMessageStatus(bool);
                        void connectPressed();
                        void sendPressed();
                        void connectEnabled();
                        void subscribePressed();
                        void subscribed();
                        void connected();
                        void showMessage(QString);
                    };
                    

                    qtmosq.h

                    #ifndef QTMOSQ_H
                    #define QTMOSQ_H
                    
                    #include "QObject"
                    #include "mosquittopp.h"
                    
                    using namespace mosqpp;
                    
                    class qtmosq : public QObject, public mosquittopp
                    {
                        Q_OBJECT
                    
                    public:
                        qtmosq(const char *id = NULL, bool clean_session = true) : mosquittopp (id, clean_session) {MID = 0;}
                        ~qtmosq() {}
                    
                        void on_connect(int result)
                        {
                            if (!result)
                            {
                                //subscribe(NULL, "$SYS/#", 2);
                                emit connected();
                            }
                            else
                                emit connectEnable();
                        }
                        void on_publish(int id)
                        {
                            MID++;
                            emit messageSent(true);
                        }
                        void on_subscribe(int mid, int qos_count, const int *granted_qos)
                        {
                            if (MID != 0)
                                emit subscribed();
                            MID++;
                        }
                        void on_message(const mosquitto_message *message)
                        {
                            if (message->payloadlen)
                            {
                                QString s(message->topic);
                                s += '>';
                                s += (char*) message->payload;
                                emit messageReceived(s);
                            }
                        }
                    
                        int* getMID() {return &MID;}
                    
                    private:
                        int MID;
                    
                    signals:
                        void connected();
                        void messageSent(bool);
                        void messageReceived(QString);
                        void connectEnable();
                        void subscribed();
                    };
                    
                    #endif // QTMOSQ_H
                    
                    

                    here above i send the code for the same.

                    if you get more please tell me.

                    J 1 Reply Last reply 15 Oct 2019, 05:00
                    0
                    • M Milav
                      15 Oct 2019, 04:53

                      @jsulm

                      i call it in mainwindow.cpp file.

                      here i have send the code snip for that portion.

                      mainwindow.cpp

                      MainWindow::MainWindow(QWidget *parent) :
                          QMainWindow(parent),
                          ui(new Ui::MainWindow)
                      {
                          ui->setupUi(this);
                          ui->send->setDisabled(true);
                          ui->message->setDisabled(true);
                          ui->subscribe->setDisabled(true);
                          ui->topic->setDisabled(true);
                      
                          ui->lineIP->setText(QString("a3jkuztr3frwt4-ats.iot.ap-south-1.amazonaws.com"));
                          ui->linePort->setText(QString("8883"));
                      
                          lib_init();
                      
                          connect (ui->connect, SIGNAL(clicked()), this, SLOT(connectPressed()));
                          connect (ui->send, SIGNAL(clicked()), this, SLOT(sendPressed()));
                          connect (ui->subscribe, SIGNAL(clicked()), this, SLOT(subscribePressed()));
                      }
                      
                      void MainWindow::connectPressed()
                      {
                          QByteArray host = ui->lineIP->text().toLocal8Bit();
                          QByteArray id = ui->lineID->text().toLocal8Bit();
                      
                          int port = 0;
                          port = ui->linePort->text().toInt();
                          if (!port)
                          {
                              ui->linePort->clear();
                              return ;
                          }
                          ui->connect->setDisabled(true);
                      
                      
                          mosq = new qtmosq(id, true);
                          int size = sizeof(*mosq);
                          qDebug() << size;
                          connect (mosq, SIGNAL(connectEnable()), this, SLOT(connectEnabled()));
                          connect (mosq, SIGNAL(subscribed()), this ,SLOT(subscribed()));
                          connect (mosq, SIGNAL(connected()), this, SLOT(connected()));
                          connect (mosq, SIGNAL(messageSent(bool)), this, SLOT(setMessageStatus(bool)));
                          connect (mosq, SIGNAL(messageReceived(QString)), this, SLOT(showMessage(QString)));
                          mosq->connect_async(host.data(), port);
                          mosq->loop_start();
                      
                      }
                      

                      mainwindow.h

                      #include <QMainWindow>
                      #include "qtmosq.h"
                      
                      namespace Ui {
                      class MainWindow;
                      }
                      
                      class MainWindow : public QMainWindow
                      {
                          Q_OBJECT
                      
                      public:
                          explicit MainWindow(QWidget *parent = 0);
                          ~MainWindow();
                      
                      private:
                          qtmosq* mosq;
                          QStringList subed;
                          QString currentTopic;
                          Ui::MainWindow *ui;
                      
                      private slots:
                          void setMessageStatus(bool);
                          void connectPressed();
                          void sendPressed();
                          void connectEnabled();
                          void subscribePressed();
                          void subscribed();
                          void connected();
                          void showMessage(QString);
                      };
                      

                      qtmosq.h

                      #ifndef QTMOSQ_H
                      #define QTMOSQ_H
                      
                      #include "QObject"
                      #include "mosquittopp.h"
                      
                      using namespace mosqpp;
                      
                      class qtmosq : public QObject, public mosquittopp
                      {
                          Q_OBJECT
                      
                      public:
                          qtmosq(const char *id = NULL, bool clean_session = true) : mosquittopp (id, clean_session) {MID = 0;}
                          ~qtmosq() {}
                      
                          void on_connect(int result)
                          {
                              if (!result)
                              {
                                  //subscribe(NULL, "$SYS/#", 2);
                                  emit connected();
                              }
                              else
                                  emit connectEnable();
                          }
                          void on_publish(int id)
                          {
                              MID++;
                              emit messageSent(true);
                          }
                          void on_subscribe(int mid, int qos_count, const int *granted_qos)
                          {
                              if (MID != 0)
                                  emit subscribed();
                              MID++;
                          }
                          void on_message(const mosquitto_message *message)
                          {
                              if (message->payloadlen)
                              {
                                  QString s(message->topic);
                                  s += '>';
                                  s += (char*) message->payload;
                                  emit messageReceived(s);
                              }
                          }
                      
                          int* getMID() {return &MID;}
                      
                      private:
                          int MID;
                      
                      signals:
                          void connected();
                          void messageSent(bool);
                          void messageReceived(QString);
                          void connectEnable();
                          void subscribed();
                      };
                      
                      #endif // QTMOSQ_H
                      
                      

                      here above i send the code for the same.

                      if you get more please tell me.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 15 Oct 2019, 05:00 last edited by jsulm
                      #10

                      @Milav So, you get that error here in MainWindow:

                      ui->connect->setDisabled(true); 
                      mosq = new qtmosq(id, true); // Is it here?
                      int size = sizeof(*mosq);
                      

                      ?
                      It should work.
                      Are there any other warnings or errors?
                      Try to do a complete rebuild: delete build directory, run qmake and build.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      M 2 Replies Last reply 15 Oct 2019, 05:08
                      0
                      • J jsulm
                        15 Oct 2019, 05:00

                        @Milav So, you get that error here in MainWindow:

                        ui->connect->setDisabled(true); 
                        mosq = new qtmosq(id, true); // Is it here?
                        int size = sizeof(*mosq);
                        

                        ?
                        It should work.
                        Are there any other warnings or errors?
                        Try to do a complete rebuild: delete build directory, run qmake and build.

                        M Offline
                        M Offline
                        Milav
                        wrote on 15 Oct 2019, 05:08 last edited by
                        #11

                        @jsulm

                        when i build the project it give me only warning like follow.

                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/qtmosq.h:14: warning: 'mosqpp::mosquittopp::mosquittopp(const char*, bool)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:94) [-Wdeprecated-declarations]
                        
                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:57: warning: 'int mosqpp::mosquittopp::connect_async(const char*, int, int)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:103) [-Wdeprecated-declarations]
                        
                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:80: warning: 'int mosqpp::mosquittopp::subscribe(int*, const char*, int)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:110) [-Wdeprecated-declarations]
                        

                        but i face segmentation fault error when i run that project, an i found the line at where i face segmentation fault.

                        it is ...

                        mosq->subscribe(NULL, "sensors/temprature", 1); // Segmentation falut
                        
                        M 1 Reply Last reply 15 Oct 2019, 06:10
                        0
                        • J jsulm
                          15 Oct 2019, 05:00

                          @Milav So, you get that error here in MainWindow:

                          ui->connect->setDisabled(true); 
                          mosq = new qtmosq(id, true); // Is it here?
                          int size = sizeof(*mosq);
                          

                          ?
                          It should work.
                          Are there any other warnings or errors?
                          Try to do a complete rebuild: delete build directory, run qmake and build.

                          M Offline
                          M Offline
                          Milav
                          wrote on 15 Oct 2019, 05:12 last edited by
                          #12

                          @jsulm

                          Hello

                          Here i have send the link at where i download the example.

                          Reference link

                          J 1 Reply Last reply 15 Oct 2019, 05:19
                          0
                          • M Milav
                            15 Oct 2019, 05:12

                            @jsulm

                            Hello

                            Here i have send the link at where i download the example.

                            Reference link

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 15 Oct 2019, 05:19 last edited by
                            #13

                            @Milav That example does exactly what I suggested you to do:

                            ui->connect->setDisabled(true);
                            
                            mosq = new qtmosq(id, false); // HERE
                            connect (mosq, SIGNAL(connectEnable()), this, SLOT(connectEnabled()));
                            

                            Did you try to build and run this example? If so - does it work?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            M 1 Reply Last reply 15 Oct 2019, 05:36
                            0
                            • J jsulm
                              15 Oct 2019, 05:19

                              @Milav That example does exactly what I suggested you to do:

                              ui->connect->setDisabled(true);
                              
                              mosq = new qtmosq(id, false); // HERE
                              connect (mosq, SIGNAL(connectEnable()), this, SLOT(connectEnabled()));
                              

                              Did you try to build and run this example? If so - does it work?

                              M Offline
                              M Offline
                              Milav
                              wrote on 15 Oct 2019, 05:36 last edited by
                              #14

                              @jsulm

                              Yes i delete the build directory and again i rebuild the whole project but i couldn't run the example. it is not work.

                              J 1 Reply Last reply 15 Oct 2019, 05:51
                              0
                              • M Milav
                                15 Oct 2019, 05:36

                                @jsulm

                                Yes i delete the build directory and again i rebuild the whole project but i couldn't run the example. it is not work.

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 15 Oct 2019, 05:51 last edited by
                                #15

                                @Milav said in segmentation fault:

                                it is not work

                                What exactly does this mean? Doesn't build? Crashes? Does not do what it should? ...?

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                M 1 Reply Last reply 15 Oct 2019, 05:56
                                0
                                • J jsulm
                                  15 Oct 2019, 05:51

                                  @Milav said in segmentation fault:

                                  it is not work

                                  What exactly does this mean? Doesn't build? Crashes? Does not do what it should? ...?

                                  M Offline
                                  M Offline
                                  Milav
                                  wrote on 15 Oct 2019, 05:56 last edited by
                                  #16

                                  @jsulm

                                  it means build successful.

                                  but it is not run, it is crashes application.

                                  means while running the application, the application are crash.

                                  with following error.

                                  "segmentation fault"

                                  and i debug the application via qDebug(), the application are crash on following line of code.

                                  mosq->subscribe(NULL, "sensors/temprature", 1); // Segmentation falut
                                  
                                  J.HilkJ 1 Reply Last reply 15 Oct 2019, 05:58
                                  0
                                  • M Milav
                                    15 Oct 2019, 05:56

                                    @jsulm

                                    it means build successful.

                                    but it is not run, it is crashes application.

                                    means while running the application, the application are crash.

                                    with following error.

                                    "segmentation fault"

                                    and i debug the application via qDebug(), the application are crash on following line of code.

                                    mosq->subscribe(NULL, "sensors/temprature", 1); // Segmentation falut
                                    
                                    J.HilkJ Offline
                                    J.HilkJ Offline
                                    J.Hilk
                                    Moderators
                                    wrote on 15 Oct 2019, 05:58 last edited by
                                    #17

                                    @Milav well, did you press connect before you pressed subscribe?

                                    If not it will crash...


                                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                    Q: What's that?
                                    A: It's blue light.
                                    Q: What does it do?
                                    A: It turns blue.

                                    M 1 Reply Last reply 15 Oct 2019, 06:05
                                    0
                                    • J.HilkJ J.Hilk
                                      15 Oct 2019, 05:58

                                      @Milav well, did you press connect before you pressed subscribe?

                                      If not it will crash...

                                      M Offline
                                      M Offline
                                      Milav
                                      wrote on 15 Oct 2019, 06:05 last edited by
                                      #18

                                      @J-Hilk

                                      I press first Connect button and than after i press subscribed button.

                                      but it is crash...

                                      J 1 Reply Last reply 15 Oct 2019, 06:10
                                      0
                                      • M Milav
                                        15 Oct 2019, 05:08

                                        @jsulm

                                        when i build the project it give me only warning like follow.

                                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/qtmosq.h:14: warning: 'mosqpp::mosquittopp::mosquittopp(const char*, bool)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:94) [-Wdeprecated-declarations]
                                        
                                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:57: warning: 'int mosqpp::mosquittopp::connect_async(const char*, int, int)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:103) [-Wdeprecated-declarations]
                                        
                                        /home/tdp0009/Teq_Projects/Aug_2019/HMI/Firmware/QT/12_oct_hmi/qt-mosquitto-master/mainwindow.cpp:80: warning: 'int mosqpp::mosquittopp::subscribe(int*, const char*, int)' is deprecated (declared at ../../../../CC_Lib/mosquitto/phytec_wega_build_websockets/usr/local/include/mosquittopp.h:110) [-Wdeprecated-declarations]
                                        

                                        but i face segmentation fault error when i run that project, an i found the line at where i face segmentation fault.

                                        it is ...

                                        mosq->subscribe(NULL, "sensors/temprature", 1); // Segmentation falut
                                        
                                        M Offline
                                        M Offline
                                        mvuori
                                        wrote on 15 Oct 2019, 06:10 last edited by
                                        #19

                                        If temprature is supposed to be temperature, this is a bug:
                                        mosq->subscribe(NULL, "sensors/temprature", 1);

                                        M 1 Reply Last reply 15 Oct 2019, 06:29
                                        0
                                        • M Milav
                                          15 Oct 2019, 06:05

                                          @J-Hilk

                                          I press first Connect button and than after i press subscribed button.

                                          but it is crash...

                                          J Offline
                                          J Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on 15 Oct 2019, 06:10 last edited by
                                          #20

                                          @Milav Did you debug to see whether mosq is not a nullptr? If it's not please provide stack trace after crash.
                                          Also, in connectPressed it does a return if port is not set - is it set if you press connect?
                                          You should really run through debugger...

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          M 1 Reply Last reply 15 Oct 2019, 06:28
                                          0

                                          4/61

                                          14 Oct 2019, 05:17

                                          57 unread
                                          • Login

                                          • Login or register to search.
                                          4 out of 61
                                          • First post
                                            4/61
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved