Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with disassembler and SIGILL signal
Forum Updated to NodeBB v4.3 + New Features

Problem with disassembler and SIGILL signal

Scheduled Pinned Locked Moved Solved General and Desktop
59 Posts 4 Posters 21.7k Views 4 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.
  • A Amaury
    21 Dec 2016, 08:56

    Alright that's clearer ^^
    So if I need to create a dangling pointer where do I need to declare it ?
    into the class itself ?

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 21 Dec 2016, 09:01 last edited by
    #41

    @Amaury
    Well you can declare it anywhere. :)
    You want to try crash on purpose`?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Amaury
      wrote on 21 Dec 2016, 09:09 last edited by
      #42

      Yes I'd like to look at all my pointers, see if there's somewhere that one is not declared or thing like that.

      M 1 Reply Last reply 21 Dec 2016, 09:45
      0
      • A Amaury
        21 Dec 2016, 09:09

        Yes I'd like to look at all my pointers, see if there's somewhere that one is not declared or thing like that.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 21 Dec 2016, 09:45 last edited by
        #43

        @Amaury

        • one is not declared
          I assume you mean instantiated or in non japanese
          new'ed
          as in
          ClassX * varX = new X()
        1 Reply Last reply
        0
        • A Offline
          A Offline
          Amaury
          wrote on 21 Dec 2016, 10:06 last edited by Amaury
          #44

          Yes that's alright .

          Btw I got a question , there's some code that I didn't develop myself and I was wondering if there could be an error in some parameters here's the setup :

          main.cpp

          
          static const QString path = "localhost";
          DataBase MemTampon::Db(path);
          
          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
          
              QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
              QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
          
              QTranslator *qtTranslator = new QTranslator;
                  qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
                  a.installTranslator(qtTranslator);
          
                  MemTampon::Db.aff_Temperature();
                  MemTampon::Db.aff_Humidite();
                  MemTampon::Db.aff_Puissance();
                  MemTampon::Db.aff_Nom_SD();
          
              MainWindow w;
              w.show();
          
              return a.exec();
          
          }
          

          memtampon.h (memtampon.cpp is empty)

          class MemTampon
          {
          public:
              static DataBase Db;
              static Options Opt;
          
          };
          
          

          and Database.cpp

          DataBase::DataBase(const QString &path)
          {
                  db = QSqlDatabase::addDatabase("QMYSQL");
                  db.setHostName("localhost");
                  db.setDatabaseName("SmartDevice_DB_V1");
                  db.setUserName("root");
                  db.setPassword("root");
          
                  if (!db.open())
                  {
                     qDebug() << "Error: connection with database fail";
                  }
                  else
                  {
                     qDebug() << "Database: connection ok";
                  }
          }
          

          I assume that with the path variable I am able to call the functions that are in my cpp but, it tells me that path is an unused parameter could it possibly give me an error ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 21 Dec 2016, 10:15 last edited by
            #45

            Its impossible to say
            But global variables are good candidate to be check. (always)

            I dont think
            static const QString path;
            can give such error.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Amaury
              wrote on 21 Dec 2016, 10:32 last edited by
              #46

              Thank you I was a little disapointed by this function and wasn't able to say if that was correct or not

              M K 2 Replies Last reply 21 Dec 2016, 10:33
              0
              • A Amaury
                21 Dec 2016, 10:32

                Thank you I was a little disapointed by this function and wasn't able to say if that was correct or not

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 21 Dec 2016, 10:33 last edited by
                #47

                @Amaury
                Well you can always single step it and see if something happens.

                1 Reply Last reply
                0
                • A Amaury
                  21 Dec 2016, 10:32

                  Thank you I was a little disapointed by this function and wasn't able to say if that was correct or not

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 21 Dec 2016, 11:08 last edited by
                  #48

                  @Amaury
                  Also you can cut the code that you suspect and see if the problem manifest itself. I wouldn't in principle initialize anything outside of main (like your database) if I can help it, that way I stumble on to less errors in my code, and thus makes for an easier time debugging. Still, my best guess is there some subtle architecture mismatch, so the compiler generates a mostly valid code. However I have no clue how to really test that at present.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Amaury
                    wrote on 21 Dec 2016, 11:08 last edited by Amaury
                    #49

                    By using step I can't see any bugs so that's not here.

                    By the way I'm using the memory check Valgind through QT and when I do a memory check thats starting but I got this message after a few seconds :

                    Analyzing memory of /home/pi/Desktop/SmartDevice/SauvegardeRASPI/New/build-SmartDevice_QT_V11-Desktop-Debug/SmartDevice_QT_V11
                        <frame>
                          <ip>0x485F6F0</ip>
                          <obj>/usr/lib/arm-linux-gnueabihf/libarmmem.so</obj>
                        </frame>
                      </stack>
                    Analyzing finished.
                    ** Unknown error **
                    

                    I followed the steps here :
                    http://doc.qt.io/qtcreator/creator-valgrind-overview.html
                    http://doc.qt.io/qtcreator/creator-analyzer.html

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Amaury
                      wrote on 21 Dec 2016, 11:15 last edited by
                      #50

                      @kshegunov
                      If I don't declare it there where could I do it ? As said before that's not a code that I did myself and I don't really understand the way that it works (how the "path" is used thorugh the different pages ...

                      K 1 Reply Last reply 21 Dec 2016, 11:16
                      0
                      • A Amaury
                        21 Dec 2016, 11:15

                        @kshegunov
                        If I don't declare it there where could I do it ? As said before that's not a code that I did myself and I don't really understand the way that it works (how the "path" is used thorugh the different pages ...

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 21 Dec 2016, 11:16 last edited by
                        #51

                        @Amaury said in Problem with disassembler and SIGILL signal:

                        If I don't declare it there where could I do it

                        From the looks of it you can safely put the db initialization in main (after you've created the application object). As for the string, it's okay to leave it as a global.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Amaury
                          wrote on 21 Dec 2016, 11:43 last edited by Amaury
                          #52

                          @kshegunov

                          I tried like that but that doesn't work got a qualified-id in declaration before '(' token error

                          static const QString path = "localhost";
                          
                          int main(int argc, char *argv[])
                          {
                              QApplication a(argc, argv);
                              DataBase MemTampon::Db(path);
                          .
                          .
                          .
                          }
                          

                          Even with the string inside the main ...

                          K 1 Reply Last reply 21 Dec 2016, 11:44
                          0
                          • A Amaury
                            21 Dec 2016, 11:43

                            @kshegunov

                            I tried like that but that doesn't work got a qualified-id in declaration before '(' token error

                            static const QString path = "localhost";
                            
                            int main(int argc, char *argv[])
                            {
                                QApplication a(argc, argv);
                                DataBase MemTampon::Db(path);
                            .
                            .
                            .
                            }
                            

                            Even with the string inside the main ...

                            K Offline
                            K Offline
                            kshegunov
                            Moderators
                            wrote on 21 Dec 2016, 11:44 last edited by
                            #53

                            It should be:

                            DataBase Db(path);
                            

                            You're not initializing a static anymore.

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              Amaury
                              wrote on 21 Dec 2016, 13:08 last edited by Amaury
                              #54

                              The problem is if I don't use a static I can't do the calls for my other functions in my Database class..

                              const QString path = "localhost";
                              
                              int main(int argc, char *argv[])
                              {
                              
                                  QApplication a(argc, argv);
                              
                              
                                  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                                  QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
                              
                                  QTranslator *qtTranslator = new QTranslator;
                                      qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
                                      a.installTranslator(qtTranslator);
                              
                                      DataBase Db(path);
                                      DataBase::Db.aff_Temperature();
                                      DataBase::Db.aff_Humidite();
                                      DataBase::Db.aff_Puissance();
                                      DataBase::Db.aff_Nom_SD();
                              
                                  MainWindow w;
                                  w.show();
                              
                              
                                  return a.exec();
                              }
                              

                              (By the way I've delete the MemTampon that I agree was useless ... )

                              EDIT : My bad I'm dumb I think ^^ for the main it's alright just had to cut out the "DataBase::"

                              But I'm doing reference to the "Db" inside another page but the call doesn't work...

                               if (Db.isOpen())
                                  {
                              
                                      Temp  = Db.aff_Temperature();
                                      Humid  = Db.aff_Humidite();
                                      Puiss  = Db.aff_Puissance();
                                      Nom = Db.aff_Nom_SD();
                                      Axe_X = Db.aff_AxeX();
                                      Axe_Y = Db.aff_AxeY();
                                      Axe_Z = Db.aff_AxeZ();
                              
                              
                              K 1 Reply Last reply 21 Dec 2016, 13:24
                              0
                              • A Amaury
                                21 Dec 2016, 13:08

                                The problem is if I don't use a static I can't do the calls for my other functions in my Database class..

                                const QString path = "localhost";
                                
                                int main(int argc, char *argv[])
                                {
                                
                                    QApplication a(argc, argv);
                                
                                
                                    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                                    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
                                
                                    QTranslator *qtTranslator = new QTranslator;
                                        qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
                                        a.installTranslator(qtTranslator);
                                
                                        DataBase Db(path);
                                        DataBase::Db.aff_Temperature();
                                        DataBase::Db.aff_Humidite();
                                        DataBase::Db.aff_Puissance();
                                        DataBase::Db.aff_Nom_SD();
                                
                                    MainWindow w;
                                    w.show();
                                
                                
                                    return a.exec();
                                }
                                

                                (By the way I've delete the MemTampon that I agree was useless ... )

                                EDIT : My bad I'm dumb I think ^^ for the main it's alright just had to cut out the "DataBase::"

                                But I'm doing reference to the "Db" inside another page but the call doesn't work...

                                 if (Db.isOpen())
                                    {
                                
                                        Temp  = Db.aff_Temperature();
                                        Humid  = Db.aff_Humidite();
                                        Puiss  = Db.aff_Puissance();
                                        Nom = Db.aff_Nom_SD();
                                        Axe_X = Db.aff_AxeX();
                                        Axe_Y = Db.aff_AxeY();
                                        Axe_Z = Db.aff_AxeZ();
                                
                                
                                K Offline
                                K Offline
                                kshegunov
                                Moderators
                                wrote on 21 Dec 2016, 13:24 last edited by kshegunov
                                #55

                                @Amaury said in Problem with disassembler and SIGILL signal:

                                if I don't use a static I can't do the calls for my other functions in my Database class..

                                Why not, you can always get the opened database (it's default named) by calling QSqlDatabase db = QSqlDatabase::database(). The QSqlDatabase class already keeps track of the opened connections for you.

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                1
                                • A Offline
                                  A Offline
                                  Amaury
                                  wrote on 21 Dec 2016, 13:28 last edited by Amaury
                                  #56

                                  So what you mean is that for now my function Database Db(path) is just to specify if the connection is opened or not ?

                                  K 1 Reply Last reply 21 Dec 2016, 13:33
                                  0
                                  • A Amaury
                                    21 Dec 2016, 13:28

                                    So what you mean is that for now my function Database Db(path) is just to specify if the connection is opened or not ?

                                    K Offline
                                    K Offline
                                    kshegunov
                                    Moderators
                                    wrote on 21 Dec 2016, 13:33 last edited by
                                    #57

                                    @Amaury
                                    Eh, yes I suppose you could say that, currently in the constructor of your object you open the database:

                                    db = QSqlDatabase::addDatabase("QMYSQL");
                                    db.setHostName("localhost");
                                    // ...
                                    

                                    so it serves as database initialization. You can do that in main() too, but that's another point. After the constructor's run, you can get the opened database the way I mentioned in my previous post. In principle it's not really needed to have a "database manager" with Qt, because the QSqlDatabase class already keeps track of the connections, as mentioned. You can look up the two functions QSqlDatabase::addDatabase and QSqlDatabase::database in the docs and I think it'll become clear from the examples there.

                                    Read and abide by the Qt Code of Conduct

                                    1 Reply Last reply
                                    1
                                    • A Offline
                                      A Offline
                                      Amaury
                                      wrote on 21 Dec 2016, 13:52 last edited by
                                      #58

                                      Alright I'm going to check and change some things to see if that deletes the Sigill signal (hope so) I come back to give you feedback.

                                      Thanks !

                                      1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        Amaury
                                        wrote on 23 Dec 2016, 08:38 last edited by
                                        #59

                                        Hi there ,

                                        I'm back again for some feedback , I changed the way I use my Database, I'm still connecting the same way, But all my functions that were in my class get swith into the only page that need those instructions .
                                        That Way I Just connect through my databse page and just make a Signal Slot use when I need it.

                                        That said , my problem isn't solve for now I though maybe it was the Databse but seems not , maybe it's my refresh timer for my UI that creates crashes , anyway I'm still triying to find the problem..

                                        If anyone could give me a clue for Valgrind to work , it's crashing a few seconds after starting the analysis and I just have the message that I post earlier.

                                        That's a big post thank's for help and if I can't get in touch happy Christmas holidays.

                                        1 Reply Last reply
                                        0

                                        41/59

                                        21 Dec 2016, 09:01

                                        • Login

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