sqlitebrowser / sqlitebrowser

Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at:
https://sqlitebrowser.org
Other
21.19k stars 2.14k forks source link

Assertion [cpMax <= pdoc->Length()] failed at ../src/Editor.cpp 6096 #2611

Closed manisandro closed 4 months ago

manisandro commented 3 years ago

Reported downstream at https://bugzilla.redhat.com/show_bug.cgi?id=1919573, reproduced with sqlitebrowser-3.12.1-2.fc34.x86_64 and qscintilla-qt5-2.11.5-2.fc34.x86_64:

  1. Open 2020k_demot.db: 2020k_demot.db.zip

  2. Execute this query:

    SELECT tp.tp_id, tp.sijainti FROM tarkistuspiste tp WHERE 5 <= (SELECT COUNT(asiakas_id) FROM tarkistus t WHERE tp.tp_id = t.tp_id GROUP BY tp_id, asiakas_id);

  3. Execute this query (same as in the step 2. except for the the missing semicolon):

    SELECT tp.tp_id, tp.sijainti FROM tarkistuspiste tp WHERE 5 <= (SELECT COUNT(asiakas_id) FROM tarkistus t WHERE tp.tp_id = t.tp_id GROUP BY tp_id, asiakas_id)

Results in

Assertion [cpMax <= pdoc->Length()] failed at ../src/Editor.cpp 6096:

Stacktrace:

#0  0x00007ffff608b292 in raise () from /lib64/libc.so.6
#1  0x00007ffff60748a4 in abort () from /lib64/libc.so.6
#2  0x00007ffff664e42d in QMessageLogger::fatal(char const*, ...) const () from /lib64/libQt5Core.so.5
#3  0x00007ffff715e256 in Scintilla::Platform::Assert (c=<optimized out>, file=<optimized out>, line=<optimized out>) at /usr/src/debug/qscintilla-2.11.5-2.fc34.x86_64/Qt5/PlatQt.cpp:1011
#4  0x00007ffff72fd8a0 in Scintilla::Editor::WndProc (this=0x5555563a44e0, iMessage=2162, wParam=0, lParam=140737488344416) at ../src/Editor.cpp:6096
#5  0x00007ffff716ec9b in QsciScintillaQt::WndProc (lParam=140737488344416, wParam=0, iMessage=2162, this=<optimized out>) at /usr/src/debug/qscintilla-2.11.5-2.fc34.x86_64/Qt5/ScintillaQt.cpp:194
#6  QsciScintillaBase::SendScintilla (this=this@entry=0x7fffe411a790, msg=msg@entry=2162, cpMin=cpMin@entry=0, cpMax=cpMax@entry=159, lpstrText=lpstrText@entry=0x5555568ad9d0 "\235\330>\003PU")
    at /usr/src/debug/qscintilla-2.11.5-2.fc34.x86_64/Qt5/qsciscintillabase.cpp:234
#7  0x00007ffff7172032 in QsciScintilla::text (this=0x7fffe411a790, start=start@entry=0, end=159, end@entry=-10704) at /usr/src/debug/qscintilla-2.11.5-2.fc34.x86_64/Qt5/qsciscintilla.cpp:2368
#8  0x000055555566e8b7 in operator() (__closure=0x555556873b60, ok=<optimized out>, status_message=..., from_position=0, to_position=-10704) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/MainWindow.cpp:1156
#9  0x0000555555690c85 in operator() (fetched_row_end=<optimized out>, fetched_row_begin=<optimized out>, __closure=0x555556873b30) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/MainWindow.cpp:1221
#10 QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1>, QtPrivate::List<int, int>, void, MainWindow::executeQuery()::<lambda(const QString&, int, int, qint64)>::<lambda(int, int)> >::call (arg=<optimized out>, f=...)
    at /usr/include/qt5/QtCore/qobjectdefs_impl.h:146
#11 QtPrivate::Functor<MainWindow::executeQuery()::<lambda(const QString&, int, int, qint64)>::<lambda(int, int)>, 2>::call<QtPrivate::List<int, int>, void> (arg=<optimized out>, f=...) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:256
#12 QtPrivate::QFunctorSlotObject<MainWindow::executeQuery()::<lambda(const QString&, int, int, qint64)>::<lambda(int, int)>, 2, QtPrivate::List<int, int>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (
    which=<optimized out>, this_=0x555556873b20, r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:443
#13 0x00007ffff684c4b0 in void doActivate<false>(QObject*, int, void**) () from /lib64/libQt5Core.so.5
#14 0x00005555556bcb29 in SqliteTableModel::finishedFetch (_t2=0, _t1=0, this=0x555555fc04d0) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/x86_64-redhat-linux-gnu/sqlitebrowser_autogen/UVLADIE3JM/moc_sqlitetablemodel.cpp:165
#15 SqliteTableModel::handleFinishedFetch (this=0x555555fc04d0, life_id=<optimized out>, fetched_row_begin=0, fetched_row_end=0) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/sqlitetablemodel.cpp:93
#16 0x00005555556bcc82 in SqliteTableModel::handleRowCountComplete (num_rows=<optimized out>, life_id=<optimized out>, this=0x555555fc04d0) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/sqlitetablemodel.cpp:102
#17 SqliteTableModel::handleRowCountComplete (this=0x555555fc04d0, life_id=<optimized out>, num_rows=<optimized out>) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/sqlitetablemodel.cpp:96
#18 0x00007ffff6843257 in QObject::event(QEvent*) () from /lib64/libQt5Core.so.5
#19 0x00007ffff79dde73 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5
#20 0x00007ffff681bf48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt5Core.so.5
#21 0x00007ffff681ec76 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /lib64/libQt5Core.so.5
#22 0x00007ffff6868c57 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /lib64/libQt5Core.so.5
#23 0x00007ffff53980ff in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#24 0x00007ffff53ebc98 in g_main_context_iterate.constprop () from /lib64/libglib-2.0.so.0
#25 0x00007ffff53959f3 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#26 0x00007ffff68686f8 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#27 0x00007ffff681a9b2 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#28 0x00007ffff6822544 in QCoreApplication::exec() () from /lib64/libQt5Core.so.5
#29 0x00005555555f5f9e in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/main.cpp:58
justinclift commented 3 years ago

Thanks for the bug report @manisandro. :smile:

justinclift commented 3 years ago

@manisandro As a note, that Bugzilla report isn't public. Going to that url gives:

You are not authorized to access bug #1919573.

... even when logged in using a (non-Red-Hat) Bugzilla account.

manisandro commented 3 years ago

Indeed, I've made it public

justinclift commented 3 years ago

Thanks @manisandro. :smile:

MKleusberg commented 3 years ago

This seems to be the problem:

8 0x000055555566e8b7 in operator() (__closure=0x555556873b60, ok=, status_message=..., from_position=0, to_position=-10704) at /usr/src/debug/sqlitebrowser-3.12.1-2.fc34.x86_64/src/MainWindow.cpp:1156

It should be around 158 instead of -10704. Unfortunately I can't reproduce this here. @manisandro Could you assist us by building a custom build with extra debug information? Hopefully that would provide us with enough information to fix this issue properly. If that's not feasible, I think we can work around this issue to some extent but it might break the query logger then.

manisandro commented 3 years ago

I'm happy to assist by build custom builds, just let me know what you need.

bk322 commented 3 years ago

Same here. I'm on Kubuntu 20.04, building latest sqlitebrowser release with the latest sqlite release:

# https://github.com/sqlitebrowser/sqlitebrowser/releases
SQLITEBROWSER_VERSION=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/sqlitebrowser/sqlitebrowser/releases/latest | sed -E 's!.+/tag/!!'`
wget -O sqlitebrowser-latest.zip https://github.com/sqlitebrowser/sqlitebrowser/archive/${SQLITEBROWSER_VERSION}.zip
unzip   sqlitebrowser-latest.zip
rm      sqlitebrowser-latest.zip
mv sqlitebrowser* sqlitebrowser-latest
cd      sqlitebrowser-latest

  perl -pe "s|endif\(EXTRAPATH\)|endif(EXTRAPATH)

# add extra library path for custom sqlite build on Linux:
set(EXTRAPATH MATCHES \"Linux\")
if(EXTRAPATH)
  find_library(LIBSQLITE \\\${LIBSQLITE_NAME} HINTS `echo ${PWD} | sed -e 's!sqlitebrowser-latest!build!'`/.libs)
  set(ADDITIONAL_INCLUDE_PATHS                      `echo ${PWD} | sed -e 's!sqlitebrowser-latest!build!'`)
endif(EXTRAPATH)
|" -i CMakeLists.txt

  mkdir build
  cd    build
    # cmake -DFORCE_INTERNAL_QSCINTILLA=ON -Dsqlcipher=0 -Wno-dev ..
    cmake -Dsqlcipher=0 -Wno-dev ..
    make
    cp sqlitebrowser ../../build/
  cd -
cd ..
sandman7920 commented 3 years ago

This is fixed with https://github.com/sqlitebrowser/sqlitebrowser/commit/367665e7f51073dbfa3c9c0c6700c0d761af3389 But is not backported to 3.12.x

EDIT: *conn = connect(model, &SqliteTableModel::finishedFetch,...) is not disconnected, and query_logger(true, ..., from_position, to_position); is called multiple times with old values for from_position and to_position, then in query_logger we have out of range exception

https://github.com/sqlitebrowser/sqlitebrowser/blob/v3.12.x/src/MainWindow.cpp#L1221 https://github.com/sqlitebrowser/sqlitebrowser/blob/v3.12.x/src/MainWindow.cpp#L1156

justinclift commented 3 years ago

We're probably overdue to making a 3.13.0 release anyway. :wink:

MKleusberg commented 3 years ago

We're probably overdue to making a 3.13.0 release anyway. wink

:+1: But let's try to get rid of qmake before, so distributors are forced to use cmake just like we do. I guess most of them already are but I'd like to avoid getting bug reports on qmake after removing it :smile:

daynebatten commented 3 years ago

Is there a workaround for this issue until the 3.13.0 release?

On Ubuntu 20.10. This happens about every 60 seconds while using the application. It used to be stable though. Is there a known earlier version I can downgrade to?

bk322 commented 3 years ago

Works in Kubuntu 20.04 with the latest continuous build:

wget -O sqlitebrowser-continuous.zip https://github.com/sqlitebrowser/sqlitebrowser/archive/refs/tags/continuous.zip
unzip   sqlitebrowser-continuous.zip
rm      sqlitebrowser-continuous.zip
mv sqlitebrowser* sqlitebrowser-continuous
cd      sqlitebrowser-continuous

  mkdir build
  cd    build
    cmake -Dsqlcipher=0 -Wno-dev ..
    make
    ./sqlitebrowser &
  cd -
cd ..
archqt commented 6 months ago

It is still crashing in version 3.12.2 with the same error

FriedrichFroebel commented 6 months ago

As mentioned above, this is only fixed in the nightlies and not yet available inside the release.

michaelsteuer commented 4 months ago

I still encountered a version of this bug in 3.12.1

console output: Assertion [cpMax <= pdoc->Length()] failed at ../src/Editor.cpp 6096

followed by SIGABORT

$ sqlitebrowser --version
DB Browser for SQLite Version 3.12.1

Built for x86_64-little_endian-lp64, running on x86_64
Qt Version 5.15.1
SQLite Version 3.33.0.
justinclift commented 4 months ago

@michaelsteuer Are you ok to try the latest development snapshot from here?

https://github.com/sqlitebrowser/sqlitebrowser/releases/tag/continuous

The problem should be fixed in that. :smile: