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. SIGSEV error on setDatabaseName
QtWS25 Last Chance

SIGSEV error on setDatabaseName

Scheduled Pinned Locked Moved Solved General and Desktop
sigsegvsetdatabasename
19 Posts 3 Posters 5.6k Views
  • 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.
  • G Offline
    G Offline
    gabor53
    wrote on 25 May 2016, 03:48 last edited by
    #1

    Hi,
    I have the following code:

       QSqlDatabase db = QSqlDatabase::addDatabase ("QSQLITE");
    //   db.setDatabaseName ("C:/Programming/Projects/FolkFriends/db.db");
       db.setDatabaseName (fileQstring);
    

    If I run the second line it runs correctly. if I run the third line it gives a SIGSEGV error.

    in the .h file:

    QString fileQstring = ("C:/Programming/Projects/FolkFriends/db.db");
    

    Please help me to figure out why I get this error message. Thank you.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 25 May 2016, 04:47 last edited by
      #2

      Why did you put the string in (...)?
      Where does it crash? I mean did you try to debug your program to see where it crashes?

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

      G 1 Reply Last reply 25 May 2016, 12:25
      0
      • J jsulm
        25 May 2016, 04:47

        Why did you put the string in (...)?
        Where does it crash? I mean did you try to debug your program to see where it crashes?

        G Offline
        G Offline
        gabor53
        wrote on 25 May 2016, 12:25 last edited by
        #3

        @jsulm I tried to debug and this line seemed to be the problem.

        K 1 Reply Last reply 25 May 2016, 17:15
        0
        • G gabor53
          25 May 2016, 12:25

          @jsulm I tried to debug and this line seemed to be the problem.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 25 May 2016, 17:15 last edited by kshegunov
          #4

          @gabor53
          SIGSEGV is a segmentation fault, which basically means you have a corrupted memory somewhere. You should track it down through the debugger. Could you provide a stack trace of the crash?

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gabor53
            wrote on 25 May 2016, 18:02 last edited by
            #5

            Can you please tell me how to do that? I' m still trying to figure out how the debugger works.

            K 1 Reply Last reply 25 May 2016, 18:05
            0
            • G gabor53
              25 May 2016, 18:02

              Can you please tell me how to do that? I' m still trying to figure out how the debugger works.

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 25 May 2016, 18:05 last edited by kshegunov
              #6

              @gabor53
              Stack trace
              This is the current stack in Qt creator. So when the crash occurs you'd right click it and choose "copy contents"/"extract" or something of that sort. Paste it somewhere online (for example codepaste.net) and post the link here.

              Read and abide by the Qt Code of Conduct

              G 1 Reply Last reply 26 May 2016, 03:08
              0
              • K kshegunov
                25 May 2016, 18:05

                @gabor53
                Stack trace
                This is the current stack in Qt creator. So when the crash occurs you'd right click it and choose "copy contents"/"extract" or something of that sort. Paste it somewhere online (for example codepaste.net) and post the link here.

                G Offline
                G Offline
                gabor53
                wrote on 26 May 2016, 03:08 last edited by
                #7

                @kshegunov
                There is nothing in the Stack.

                K 1 Reply Last reply 26 May 2016, 03:22
                0
                • G gabor53
                  26 May 2016, 03:08

                  @kshegunov
                  There is nothing in the Stack.

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 26 May 2016, 03:22 last edited by
                  #8

                  @gabor53
                  Are you sure you're looking at the stack window, there are other debugger windows as well? If you don't have a stack while debugging, then that means you're not running the program through the debugger ... Can you set breakpoints and does the program stop at those?

                  Read and abide by the Qt Code of Conduct

                  G 1 Reply Last reply 26 May 2016, 12:47
                  0
                  • K kshegunov
                    26 May 2016, 03:22

                    @gabor53
                    Are you sure you're looking at the stack window, there are other debugger windows as well? If you don't have a stack while debugging, then that means you're not running the program through the debugger ... Can you set breakpoints and does the program stop at those?

                    G Offline
                    G Offline
                    gabor53
                    wrote on 26 May 2016, 12:47 last edited by
                    #9

                    @kshegunov
                    I use ->Debug -> Start Debugging -> Start Debugging (F5). How else can I run to see something in stack?

                    K 1 Reply Last reply 27 May 2016, 00:14
                    0
                    • G Offline
                      G Offline
                      gabor53
                      wrote on 26 May 2016, 12:50 last edited by
                      #10

                      I have the following in the Debug log:

                      <95python theDumper.stackListFrames({"limit":20,"options":"",})

                      &"python theDumper.stackListFrames({"limit":20,"options":"",})\n"
                      &"Traceback (most recent call last):\n"
                      &" File "<string>", line 1, in <module>\n"
                      &"AttributeError: Dumper instance has no attribute 'stackListFrames'\n"
                      &"Error while executing Python code.\n"
                      95^error,msg="Error while executing Python code."

                      1 Reply Last reply
                      0
                      • G gabor53
                        26 May 2016, 12:47

                        @kshegunov
                        I use ->Debug -> Start Debugging -> Start Debugging (F5). How else can I run to see something in stack?

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 27 May 2016, 00:14 last edited by
                        #11

                        @gabor53

                        I use ->Debug -> Start Debugging -> Start Debugging (F5). How else can I run to see something in stack?

                        No, you're doing it correctly.

                        &"AttributeError: Dumper instance has no attribute 'stackListFrames'\n"
                        &"Error while executing Python code.\n"

                        This however leads me to believe there's something wrong with the debugger, or rather the debugger wrapper. What OS, Qt Creator version and debugger are you using?

                        Read and abide by the Qt Code of Conduct

                        G 1 Reply Last reply 27 May 2016, 01:19
                        0
                        • K kshegunov
                          27 May 2016, 00:14

                          @gabor53

                          I use ->Debug -> Start Debugging -> Start Debugging (F5). How else can I run to see something in stack?

                          No, you're doing it correctly.

                          &"AttributeError: Dumper instance has no attribute 'stackListFrames'\n"
                          &"Error while executing Python code.\n"

                          This however leads me to believe there's something wrong with the debugger, or rather the debugger wrapper. What OS, Qt Creator version and debugger are you using?

                          G Offline
                          G Offline
                          gabor53
                          wrote on 27 May 2016, 01:19 last edited by
                          #12

                          @kshegunov
                          I use Windows 10, Qt 5.6, Debugger: GNU gdb 7.8 for MinGW 4.9.2 32 bit and I use MinGW 4.9.2 32 bit compiler.

                          K 1 Reply Last reply 27 May 2016, 01:22
                          0
                          • G gabor53
                            27 May 2016, 01:19

                            @kshegunov
                            I use Windows 10, Qt 5.6, Debugger: GNU gdb 7.8 for MinGW 4.9.2 32 bit and I use MinGW 4.9.2 32 bit compiler.

                            K Offline
                            K Offline
                            kshegunov
                            Moderators
                            wrote on 27 May 2016, 01:22 last edited by
                            #13

                            @gabor53

                            Okay, it should work. Are you building in debug mode? Can you paste (somewhere online) the compile lines and/or linker line from building as well?

                            Read and abide by the Qt Code of Conduct

                            G 2 Replies Last reply 27 May 2016, 02:58
                            0
                            • K kshegunov
                              27 May 2016, 01:22

                              @gabor53

                              Okay, it should work. Are you building in debug mode? Can you paste (somewhere online) the compile lines and/or linker line from building as well?

                              G Offline
                              G Offline
                              gabor53
                              wrote on 27 May 2016, 02:58 last edited by
                              #14

                              @kshegunov
                              Yes, I'm building in debug mode.

                              Is this what you needed?

                              configure -static -platform win32-g++ -prefix "C:\Qt\Qt5.4.0_Static" -release -opensource -confirm-license -nomake examples -nomake tests -nomake tools -opengl desktop -no-angle -qt-sql-sqlite -make libs -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype

                              1 Reply Last reply
                              0
                              • K kshegunov
                                27 May 2016, 01:22

                                @gabor53

                                Okay, it should work. Are you building in debug mode? Can you paste (somewhere online) the compile lines and/or linker line from building as well?

                                G Offline
                                G Offline
                                gabor53
                                wrote on 27 May 2016, 04:07 last edited by
                                #15

                                @kshegunov
                                I finally managed to get the stack. Here is the link to it:
                                stack
                                I installed the latest update and it made debug work better.

                                K 1 Reply Last reply 27 May 2016, 05:00
                                0
                                • G gabor53
                                  27 May 2016, 04:07

                                  @kshegunov
                                  I finally managed to get the stack. Here is the link to it:
                                  stack
                                  I installed the latest update and it made debug work better.

                                  K Offline
                                  K Offline
                                  kshegunov
                                  Moderators
                                  wrote on 27 May 2016, 05:00 last edited by kshegunov
                                  #16

                                  @gabor53

                                  I finally managed to get the stack.

                                  Great!

                                  Here is the link to it

                                  Yes, that is superb. See the top of the stack (the reason I requested it in the first place):

                                  1  QBasicAtomicOps<4>::ref<int>                                     qatomic_x86.h                  181  0x6b9cebc8 
                                  2  QBasicAtomicInteger<int>::ref                                    qbasicatomic.h                 129  0x6b9e1070 
                                  3  QtPrivate::RefCount::ref                                         qrefcount.h                    55   0x6ba534a7 
                                  4  QString::operator=                                               qstring.cpp                    1739 0x6b7f67d3 
                                  5  QFile::QFile                                                     qfile.cpp                      255  0x6b85cdb4 
                                  6  Additem::FunctAddtoDb                                            additem.cpp                    57   0x40453b
                                  

                                  This is what functions were entered at the point where the crash occurred. Notice there's no mention of QSqlDatabase at all. :)

                                  So, my next question would be, what do you have in additem.cpp at line 57 (this would be called from your review::on_submit_Button_clicked slot at line 96). There's a QFile instance creation that crashes (or rather its constructor argument causes the crash).

                                  Read and abide by the Qt Code of Conduct

                                  G 1 Reply Last reply 27 May 2016, 13:07
                                  0
                                  • K kshegunov
                                    27 May 2016, 05:00

                                    @gabor53

                                    I finally managed to get the stack.

                                    Great!

                                    Here is the link to it

                                    Yes, that is superb. See the top of the stack (the reason I requested it in the first place):

                                    1  QBasicAtomicOps<4>::ref<int>                                     qatomic_x86.h                  181  0x6b9cebc8 
                                    2  QBasicAtomicInteger<int>::ref                                    qbasicatomic.h                 129  0x6b9e1070 
                                    3  QtPrivate::RefCount::ref                                         qrefcount.h                    55   0x6ba534a7 
                                    4  QString::operator=                                               qstring.cpp                    1739 0x6b7f67d3 
                                    5  QFile::QFile                                                     qfile.cpp                      255  0x6b85cdb4 
                                    6  Additem::FunctAddtoDb                                            additem.cpp                    57   0x40453b
                                    

                                    This is what functions were entered at the point where the crash occurred. Notice there's no mention of QSqlDatabase at all. :)

                                    So, my next question would be, what do you have in additem.cpp at line 57 (this would be called from your review::on_submit_Button_clicked slot at line 96). There's a QFile instance creation that crashes (or rather its constructor argument causes the crash).

                                    G Offline
                                    G Offline
                                    gabor53
                                    wrote on 27 May 2016, 13:07 last edited by
                                    #17

                                    @kshegunov

                                    Line 57 is

                                    QFile file(fileName);
                                    

                                    File name is defined in an other function:

                                    QString Additem::findimage()
                                    {
                                        Image_Button->setStyleSheet ("QPushButton{"
                                                                     "background-color:rgb(0, 255,0);"
                                                                     "border-style: outset;"
                                                                     "border-width: 2px;"
                                                                     "border-radius: 10px;"
                                                                     "border-color: beige;"
                                                                     "font: bold 14px;"
                                                                     "min-width: 10em;"
                                                                     "padding: 6px;}"
                                                                     );
                                    
                                        QString sPath = "C:/";
                                    
                                        QFileDialog *fileDialog = new QFileDialog;
                                    
                                        fileName = fileDialog->getOpenFileName(this,
                                                      tr("Finding Friend's Image"),sPath, tr("Image Files (*.png *.jpg *.bmp)"));
                                    
                                    
                                        display_Label->setFixedSize (100,100);
                                    
                                           if(fileName=="")
                                               {
                                                   qDebug() << "No image was chosen.";
                                                   QMessageBox::warning (this,"Error 1002","No image was choosen!");
                                               }
                                               else
                                               {
                                                  qDebug() << "Image was chosen!";
                                    
                                                  QPixmap pix(fileName);
                                    
                                                  int w = display_Label->width ();
                                                  int h = display_Label->height ();
                                                  display_Label->setPixmap (pix.scaled(w,h,Qt::KeepAspectRatio));
                                    
                                                  grid->addWidget (display_Label,2,2,3,1,Qt::AlignLeft);
                                    
                                           }
                                    
                                           return fileName;
                                    }
                                    
                                    K 1 Reply Last reply 27 May 2016, 18:41
                                    0
                                    • G gabor53
                                      27 May 2016, 13:07

                                      @kshegunov

                                      Line 57 is

                                      QFile file(fileName);
                                      

                                      File name is defined in an other function:

                                      QString Additem::findimage()
                                      {
                                          Image_Button->setStyleSheet ("QPushButton{"
                                                                       "background-color:rgb(0, 255,0);"
                                                                       "border-style: outset;"
                                                                       "border-width: 2px;"
                                                                       "border-radius: 10px;"
                                                                       "border-color: beige;"
                                                                       "font: bold 14px;"
                                                                       "min-width: 10em;"
                                                                       "padding: 6px;}"
                                                                       );
                                      
                                          QString sPath = "C:/";
                                      
                                          QFileDialog *fileDialog = new QFileDialog;
                                      
                                          fileName = fileDialog->getOpenFileName(this,
                                                        tr("Finding Friend's Image"),sPath, tr("Image Files (*.png *.jpg *.bmp)"));
                                      
                                      
                                          display_Label->setFixedSize (100,100);
                                      
                                             if(fileName=="")
                                                 {
                                                     qDebug() << "No image was chosen.";
                                                     QMessageBox::warning (this,"Error 1002","No image was choosen!");
                                                 }
                                                 else
                                                 {
                                                    qDebug() << "Image was chosen!";
                                      
                                                    QPixmap pix(fileName);
                                      
                                                    int w = display_Label->width ();
                                                    int h = display_Label->height ();
                                                    display_Label->setPixmap (pix.scaled(w,h,Qt::KeepAspectRatio));
                                      
                                                    grid->addWidget (display_Label,2,2,3,1,Qt::AlignLeft);
                                      
                                             }
                                      
                                             return fileName;
                                      }
                                      
                                      K Offline
                                      K Offline
                                      kshegunov
                                      Moderators
                                      wrote on 27 May 2016, 18:41 last edited by
                                      #18

                                      @gabor53 said:

                                      Line 57 is
                                      QFile file(fileName);

                                      Then indeed, this is somehow the reason for the crash. You should investigate with the debugger what exactly causes it. Stop it before the object is created, see what the file name variable contains. Perhaps check if everything is fine with how you create it or assign its value.

                                      Read and abide by the Qt Code of Conduct

                                      G 1 Reply Last reply 30 May 2016, 03:29
                                      0
                                      • K kshegunov
                                        27 May 2016, 18:41

                                        @gabor53 said:

                                        Line 57 is
                                        QFile file(fileName);

                                        Then indeed, this is somehow the reason for the crash. You should investigate with the debugger what exactly causes it. Stop it before the object is created, see what the file name variable contains. Perhaps check if everything is fine with how you create it or assign its value.

                                        G Offline
                                        G Offline
                                        gabor53
                                        wrote on 30 May 2016, 03:29 last edited by
                                        #19

                                        @kshegunov
                                        Finally I figured out that the problem is the missing

                                        QSqlDatabase::removeDatabase ();
                                        

                                        after

                                        db.close();
                                        

                                        Thank you for your help!!!

                                        1 Reply Last reply
                                        0

                                        3/19

                                        25 May 2016, 12:25

                                        topic:navigator.unread, 16
                                        • Login

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