Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when drag and dropping a table from another DB4S instance #1288

Closed
4 of 14 tasks
mgrojo opened this issue Jan 8, 2018 · 9 comments
Closed
4 of 14 tasks
Assignees
Labels
bug Confirmed bugs or reports that are very likely to be bugs. crash

Comments

@mgrojo
Copy link
Member

mgrojo commented Jan 8, 2018

Details for the issue

Open two DB4S instances.
Drag a table from the Database Structure of one instance and drop in the same tab of the other.
Tree is refreshed and the new is present in the database.
Change to the Browse Data tab.
Receiving DB4S instance crashes with the following backtrace:

Thread 1 "sqlitebrowser" received signal SIGSEGV, Segmentation fault.
0x0000000000716840 in SqliteTableModel::setTable (this=0x10519c0, table=..., 
    sortColumn=0, sortOrder=Qt::AscendingOrder, display_format=...)
    at /home/mgr/src/sqlitebrowser/src/sqlitetablemodel.cpp:71
71	    if(m_db.getObjectByName(table)->type() == sqlb::Object::Types::Table)
(gdb) bt
#0  0x0000000000716840 in SqliteTableModel::setTable (this=0x10519c0, 
    table=..., sortColumn=0, sortOrder=Qt::AscendingOrder, display_format=...)
    at /home/mgr/src/sqlitebrowser/src/sqlitetablemodel.cpp:71
#1  0x00000000006a47fc in MainWindow::populateTable (this=0x1056bb0)
    at /home/mgr/src/sqlitebrowser/src/MainWindow.cpp:509
#2  0x00000000006a9f01 in MainWindow::mainTabSelected (this=0x1056bb0, 
    tabindex=1) at /home/mgr/src/sqlitebrowser/src/MainWindow.cpp:1214
#3  0x00000000007afa11 in MainWindow::qt_static_metacall (_o=0x1056bb0, 
    _c=QMetaObject::InvokeMetaMethod, _id=51, _a=0x7fffffffcd80)
    at /home/mgr/src/sqlitebrowser/moc_MainWindow.cpp:493
#4  0x00007ffff6d0bd2a in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff777aace in QTabWidget::currentChanged(int) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#6  0x00007ffff777cf57 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#7  0x00007ffff6d0bd2a in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007ffff7770b3e in QTabBar::currentChanged(int) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007ffff7774fe3 in QTabBar::setCurrentIndex(int) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007ffff7776af0 in QTabBar::mousePressEvent(QMouseEvent*) ()
---Type <return> to continue, or q <return> to quit---
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x00007ffff761340f in QWidget::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007ffff7778f53 in QTabBar::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff75d005c in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007ffff75d5c19 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff6cdd38b in QCoreApplication::notifyInternal(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ffff75d4b32 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff762d5bb in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff762fb7b in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff75d005c in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff75d5516 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff6cdd38b in QCoreApplication::notifyInternal(QObject*, QEvent*)
---Type <return> to continue, or q <return> to quit---
    () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007ffff701f4e1 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#23 0x00007ffff70211a5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#24 0x00007ffff7004f08 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x00007fffeecb5200 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#26 0x00007ffff5076197 in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007ffff50763f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007ffff507649c in g_main_context_iteration ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007ffff6d337cf in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x00007ffff6cdab4a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007ffff6ce2bec in QCoreApplication::exec() ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#32 0x0000000000771d58 in main (argc=2, argv=0x7fffffffde68)
    at /home/mgr/src/sqlitebrowser/src/main.cpp:13
(gdb) info args
this = 0x10519c0
table = @0x7fffffffcae0: {m_schema = {static null = {<No data fields>}, 
    d = 0x7ffff6db03e0 <QArrayData::shared_null>}, m_name = {
    static null = {<No data fields>}, 
    d = 0x7ffff6db03e0 <QArrayData::shared_null>}}
sortColumn = 0
sortOrder = Qt::AscendingOrder
display_format = @0x7fffffffcb10: {
  d = 0x7ffff6db03e0 <QArrayData::shared_null>}

Useful extra information

I'm opening this issue because:

  • DB4S is crashing
  • DB4S has a bug
  • DB4S needs a feature
  • DB4S has another problem

I'm using DB4S on:

  • Windows: ( version: ___ )
  • Linux: ( distro: Ubuntu 16.04)
  • Mac OS: ( version: ___ )
  • Other: ___

I'm using DB4S version:

  • 3.10.1
  • 3.10.0
  • 3.9.1
  • Other: b08960f

I have also:

@mgrojo mgrojo added bug Confirmed bugs or reports that are very likely to be bugs. crash labels Jan 8, 2018
@justinclift
Copy link
Member

Interesting. What's the value of table in the receiving DB4S instance when it crashes?

@mgrojo
Copy link
Member Author

mgrojo commented Jan 8, 2018

It's:

table = @0x7fffffffcae0: {m_schema = {static null = {<No data fields>}, 
    d = 0x7ffff6db03e0 <QArrayData::shared_null>}, m_name = {
    static null = {<No data fields>}, 
    d = 0x7ffff6db03e0 <QArrayData::shared_null>}}

That explains the crash. Everything is null, including the m_db member in line sqlitetablemodel.cpp:71

It seems an incorrect initialisation after refreshing the database.

@justinclift
Copy link
Member

Yep. Looking at that backtrace, this seems to be the culprit code:

// Set new table
if(!storedDataFound)
{
// No stored settings found.
// Set table name and apply default display format settings
m_browseTableModel->setTable(tablename, 0, Qt::AscendingOrder);

Line 509 there is the one calling SetTable() with the bad value.

Looking back a few lines, line 474 looks interesting:

sqlb::ObjectIdentifier tablename = currentlyBrowsedTableName();

That currentlyBrowsedTableName() function might be giving things incorrect data.

On the other hand, this is all inside the populateTable() method. Maybe the first few lines of code for that need a few more checks for invalid ?

This is all just me guessing though. 😄

MKleusberg added a commit that referenced this issue Jan 15, 2018
When dragging and dropping a table from one instance of the application
to the other, the tree structure representing the database was broken.
We would show the 'Browsables' and 'All' nodes at the top level instead
of the child nodes of the 'All' node. This happened because after
dropping a table, we would reload the database structure and rebuild the
tree structure but didn't notify the tree view in the main window about
the update. This is fixed by this commit, so the main window's widgets
are always notified about the new tree structure.

See issue #1288.
@MKleusberg
Copy link
Member

The problem actually happens a bit earlier. You can see, that after dropping a table onto the structure view, the tree structure looks different: it's not longer Tables/Views/Indices/Triggers but Browsables/All instead. This happened essentially because whenever the tree structure is updated, we need to notify the main window because some code in there restricts the structure view to the bits in the 'All' node and the browse data combobox to the 'Browsables' node. In this case here however we didn't notify the main window, so the restriction bits weren't executed. The crash in the Browse Data tab is then only a follow up issue on this 😉

Anyway, I think I have fixed the issue. Can you double check, @mgrojo? 😄

@justinclift
Copy link
Member

Awesome. Thanks @MKleusberg. 😄

@mgrojo
Copy link
Member Author

mgrojo commented Jan 15, 2018

Perfect! It's working now. I don't know how I could overlooked that change in the tree, but I took it as a mere collapse of the items.

Thanks @MKleusberg

@mgrojo
Copy link
Member Author

mgrojo commented Jan 18, 2018

@MKleusberg I just noticed that now the same is happening when you change the schema line-break setting and save the preferences. It was working 39a5460 so I guess that the change fix one situation and breaks the other. I've looked a bit at it but don't know how to solve it.

@mgrojo mgrojo reopened this Jan 18, 2018
MKleusberg added a commit that referenced this issue Jan 26, 2018
This is fixing a follow-up issue of
012ad92.

See issue #1288.
@MKleusberg
Copy link
Member

Can you try with the latest fix? I hope it's working in all cases now 😉

@mgrojo
Copy link
Member Author

mgrojo commented Jan 26, 2018

Perfect. It's no longer happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs. crash
Projects
None yet
Development

No branches or pull requests

4 participants