Bug 356888 - Kexi crashes at the attempt to create a table row (invalid table)
Summary: Kexi crashes at the attempt to create a table row (invalid table)
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Tables (show other bugs)
Version: 2.9.10
Platform: Arch Linux Linux
: NOR crash
Target Milestone: 2.9.11
Assignee: Jarosław Staniek
URL:
Keywords: drkonqi
: 357025 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-18 22:54 UTC by Jan
Modified: 2016-01-21 22:32 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.9.11


Attachments
Before crash. List interface seems to be broken. (41.77 KB, image/png)
2015-12-18 22:59 UTC, Jan
Details
The Database file. (17.00 KB, application/x-sqlite3)
2015-12-19 14:12 UTC, Jan
Details
The same test file as original but with added 'cast' query, form, report (18.00 KB, application/x-kexiproject-sqlite2)
2015-12-31 10:52 UTC, Jarosław Staniek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2015-12-18 22:54:15 UTC
Application: kexi (2.9.10)
KDE Platform Version: 4.14.14
Qt Version: 4.8.7
Operating System: Linux 4.2.5-1-ARCH x86_64
Distribution (Platform): Archlinux Packages

-- Information about the crash:
This Bug appeared on the third table I made in the Design view. I changed to the Data view and wanted to fill the table with data.

- What I was doing when the application crashed:
 The Crash is reproducible either when clicking the +-symbol  on the upper left side of the list or when clicking on the +-symbol on the lower border.

- Unusual behavior I noticed:
As the screenshot shows the list isn't initialized correctly.

I can reproduce the crash every time I reload the database file. If I delete the table and recreate it it leads to the same problem.

-- Backtrace:
Application: Kexi (kexi), signal: Segmentation fault
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[KCrash Handler]
#6  0x00007f2aabbf90c5 in KexiTableScrollArea::keyPressEvent(QKeyEvent*) () from /usr/lib/libkexidatatable.so.14
#7  0x00007f2ad31b56b3 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
#8  0x00007f2ad357a7ee in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
#9  0x00007f2ad360019b in QAbstractScrollArea::event(QEvent*) () from /usr/lib/libQtGui.so.4
#10 0x00007f2aabbf9ed7 in KexiTableScrollArea::event(QEvent*) () from /usr/lib/libkexidatatable.so.14
#11 0x00007f2ad315e39c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#12 0x00007f2ad3166543 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#13 0x00007f2ad0c3e8aa in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#14 0x00007f2ad2bf054d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
#15 0x00007f2ad3204493 in ?? () from /usr/lib/libQtGui.so.4
#16 0x00007f2ad32049a2 in ?? () from /usr/lib/libQtGui.so.4
#17 0x00007f2ad31de6d6 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/libQtGui.so.4
#18 0x00007f2ad3207322 in ?? () from /usr/lib/libQtGui.so.4
#19 0x00007f2acec2cdc7 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#20 0x00007f2acec2d020 in ?? () from /usr/lib/libglib-2.0.so.0
#21 0x00007f2acec2d0cc in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#22 0x00007f2ad2c20834 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#23 0x00007f2ad32073f6 in ?? () from /usr/lib/libQtGui.so.4
#24 0x00007f2ad2beedc1 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#25 0x00007f2ad2bef135 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#26 0x00007f2ad2bf4ad9 in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#27 0x0000000000400979 in ?? ()
#28 0x00007f2ad26d0610 in __libc_start_main () from /usr/lib/libc.so.6
#29 0x00000000004009e9 in _start ()

Reported using DrKonqi
Comment 1 Jan 2015-12-18 22:59:07 UTC
Created attachment 96196 [details]
Before crash. List interface seems to be broken.
Comment 2 Jarosław Staniek 2015-12-18 23:08:33 UTC
Thanks,
It would be useful to have the database attached or screenshots of: table design and query design (or SQL).
Comment 3 Jan 2015-12-19 14:12:47 UTC
Created attachment 96200 [details]
The Database file.

Thanks for the quick response. Sorry I forgot to deliver more information. This is the relevant database.
Comment 4 Jarosław Staniek 2015-12-24 12:18:57 UTC
Confirmed, fix in progress, thanks!
Comment 5 Jarosław Staniek 2015-12-24 12:25:50 UTC
Kexi broke the table internally in some way, this will be fixed so the "new" row will appear.

Aside of that, even in case of the logical table defect (https://bugsfiles.kde.org/attachment.cgi?id=96196) Kexi should not crash but display error without allowing to proceed with data entry. And this is second fix we should have.
Comment 6 Jarosław Staniek 2015-12-24 14:59:30 UTC
*** Bug 357025 has been marked as a duplicate of this bug. ***
Comment 7 Jarosław Staniek 2015-12-24 22:25:01 UTC
Recommended read, a comment to a duplicated report:

https://bugs.kde.org/show_bug.cgi?id=357025#c4

Here the reserved word is probably "CAST" used as a table name.

sqlite3 command line tool automatically escapes the word. Kexi does not. The comment linked above explains why and what can be offered instead.

Feel free to comment.
Comment 8 Jarosław Staniek 2015-12-24 22:26:24 UTC
Solution for Kexi 2.9 would be to not using reserved words, i.e. "cast1" or "cast_" instead of "cast".
Comment 9 Jarosław Staniek 2015-12-31 10:52:21 UTC
Created attachment 96375 [details]
The same test file as original but with added 'cast' query, form, report

The same test file as original but with added 'cast' query, form, report; all these use the 'cast' table so after the fix Kexi should not allow to open them in data view.
Comment 10 Jarosław Staniek 2015-12-31 10:55:21 UTC
A complete fix in review: https://phabricator.kde.org/D726
Comment 11 Jarosław Staniek 2016-01-04 11:03:45 UTC
Git commit 01983252eda7087c5ff7d6971570d6d9b43559c8 by Jaroslaw Staniek.
Committed on 31/12/2015 at 15:17.
Pushed by staniek into branch 'calligra/2.9'.

Kexi: Do not switch to Data View if fetching records failed, show clear message

Summary:
In particular this covers the cases:
- reserved word used for table name (we're not supporting it in Kexi 2.x, see bug 356888 and example attached there)
- reserved word used for field name (we're not supporting it in Kexi 2.x, see bug 357025 and example attached there)
- any data fetching errors
- all the above is supported not only for tables (as the bug report suggests) but also for queries, forms, reports, csv export
- a few API changes were required for reports

Also display better error message; in addition to "Opening object "cast" failed. Switching to other view failed (Data View)." this is displayed in the details (examples):
- "Error opening database cursor. near ".": syntax error"
- exact SQL statement
FIXED-IN:2.9.11

Test Plan:
Open the 356888-Test01.kexi file attached at https://bugs.kde.org/show_bug.cgi?id=356888#attach_96375 and test the following:

- open the 'cast' table in data view mode
- open the 'cast' query in data view mode
- open the 'cast' form in data view mode
- open the 'cast' report in data view mode
- right-click the 'cast' table and pick Export -> To Clipboard
- right-click the 'cast' table and pick Export -> To File...

In all these cases error like this should appear:
"Opening object "cast" failed. Switching to other view failed (Data View)
Error opening database cursor. near ".": syntax error
SQL statement: SELECT movies_id, person_id, id, cast.OID FROM cast ORDER BY id"

And Kexi should refuse opening the data view.

Also opeining any of these objects in design view works. Then Kexi should not allow to switch to data view, displaying the same error.

Reviewers: piggz

Subscribers: Kexi-Devel-list

Differential Revision: https://phabricator.kde.org/D726

M  +27   -0    kexi/core/KexiView.cpp
M  +9    -0    kexi/core/KexiView.h
M  +2    -1    kexi/core/kexi.cpp
M  +5    -2    kexi/core/kexi.h
M  +3    -1    kexi/core/kexiproject.cpp
M  +23   -8    kexi/plugins/forms/kexiformview.cpp
M  +1    -1    kexi/plugins/forms/kexiformview.h
M  +13   -6    kexi/plugins/queries/kexiqueryview.cpp
M  +25   -21   kexi/plugins/reports/kexidbreportdata.cpp
M  +5    -2    kexi/plugins/reports/kexidbreportdata.h
M  +19   -22   kexi/plugins/reports/kexireportview.cpp
M  +0    -1    kexi/plugins/reports/kexireportview.h
M  +17   -5    kexi/plugins/reports/kexisourceselector.cpp
M  +8    -5    kexi/plugins/tables/kexitabledesigner_dataview.cpp
M  +7    -2    kexi/widget/tableview/KexiDataTableScrollArea.cpp
M  +6    -5    kexi/widget/tableview/KexiDataTableView.cpp
M  +2    -3    kexi/widget/tableview/KexiDataTableView.h
M  +17   -23   libs/koreport/renderer/KoReportPage.cpp
M  +131  -107  libs/koreport/renderer/KoReportPreRenderer.cpp
M  +4    -3    libs/koreport/renderer/KoReportPreRenderer.h
M  +3    -3    libs/koreport/tests/KoReportTest.cpp
M  +10   -10   plan/libs/ui/reports/reportview.cpp
M  +0    -1    plan/libs/ui/reports/reportview.h

http://commits.kde.org/calligra/01983252eda7087c5ff7d6971570d6d9b43559c8