Bug 104227 - Firebird: Crash when changing data in a table and trying to switch to next row
Summary: Firebird: Crash when changing data in a table and trying to switch to next row
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
5.3.0.0.beta1
Hardware: All All
: highest critical
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.3.0.1
Keywords: haveBacktrace
Depends on:
Blocks: Database-Firebird-Default
  Show dependency treegraph
 
Reported: 2016-11-28 15:56 UTC by Robert Großkopf
Modified: 2016-12-14 16:47 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of test file on loading in master alpha 540 (28.67 KB, image/png)
2016-11-29 11:46 UTC, Alex Thurgood
Details
bt with symbols (64.63 KB, text/plain)
2016-12-04 12:13 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2016-11-28 15:56:08 UTC
Open a *.odb-file connected to internal Firebird (FB 3 - LO 5.3). Example see here:
https://bugs.documentfoundation.org/attachment.cgi?id=129051
Input some value in one table.
Save the row with changing to next row.
Go back to the first row.
Change the enty.
Go to next row.
LO will crash immediately.

Tested with 
Version: 5.3.0.0.beta1
Build-ID: 690f553ecb3efd19143acbf01f3af4e289e94536
CPU-Threads: 4; BS-Version: Linux 4.1; UI-Render: Standard; VCL: kde4; Layout-Engine: neu; 
Gebietsschema: de-DE (de_DE.UTF-8); Calc: group
Comment 1 Robert Großkopf 2016-11-28 16:07:53 UTC
Same behavior here with
Version: 5.3.0.0.alpha1+
Build ID: 883024d657fb45c7da459017d2f936aac5644bfb
CPU Threads: 4; OS Version: Linux 4.1; UI Render: default; VCL: kde4; Layout Engine: new; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2016-11-21_22:42:51
Locale: de-DE (de_DE.UTF-8); Calc: group

Changing column and moving next row - crash of whole LO.
Comment 2 ribotb 2016-11-28 16:28:57 UTC
Reproduce with a new table in a database.
But with an exusting table, LO crashes only when closing and saving table.

Version: 5.4.0.0.alpha0+
Build ID: 719f7cb94ce783349fb1cf366a78edd9996d3e37
CPU Threads: 2; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2016-11-27_03:58:17
Locale: fr-FR (fr_FR); Calc: group
Comment 3 Robert Großkopf 2016-11-28 20:17:56 UTC
(In reply to ribotb from comment #2)

> Version: 5.4.0.0.alpha0+

Could you please give me a hint where to search for this version? Couldn't find it in the daily-folder.
Comment 4 Lionel Elie Mamane 2016-11-29 05:51:04 UTC
(In reply to robert from comment #3)
> (In reply to ribotb from comment #2)
> 
> > Version: 5.4.0.0.alpha0+
> 
> Could you please give me a hint where to search for this version? Couldn't
> find it in the daily-folder.

http://dev-builds.libreoffice.org/daily/master/
Comment 5 Alex Thurgood 2016-11-29 11:46:06 UTC
I can't test this on my current master build, as the test file fails to draw any UI elements other than a grey application window and the two white background window frames, per attached screenshot...
Comment 6 Alex Thurgood 2016-11-29 11:46:59 UTC
Created attachment 129111 [details]
Screenshot of test file on loading in master alpha 540
Comment 7 Robert Großkopf 2016-11-29 14:46:02 UTC
(In reply to Lionel Elie Mamane from comment #4)
> (In reply to robert from comment #3)
> > (In reply to ribotb from comment #2)
> > 
> > > Version: 5.4.0.0.alpha0+
> > 
> > Could you please give me a hint where to search for this version? Couldn't
> > find it in the daily-folder.
> 
> http://dev-builds.libreoffice.org/daily/master/

Seems there is nothing for Linux 64bit rpm. So no test possible here.
Comment 8 Buovjaga 2016-11-29 19:58:27 UTC
NEW per comment 2
Comment 9 Robert Großkopf 2016-12-03 08:00:21 UTC
Reproduced also with
Version: 5.4.0.0.alpha0+
Build ID: 150afc29c951d5fc9c40ff8a72f5178c32383f8c
CPU Threads: 4; OS Version: Linux 4.1; UI Render: default; VCL: kde4; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2016-12-03_01:02:49
Locale: de-DE (de_DE.UTF-8); Calc: group

on OpenSUSE 42.1 64bit rpm Linux
Comment 10 Julien Nabet 2016-12-04 11:46:29 UTC
On pc Debian x86-64 with master sources updated yesterday (+enable-dbgutil and gtk3), application doesn't react after giving a try and I must reboot my laptop.
Comment 11 Julien Nabet 2016-12-04 11:49:15 UTC
sorry, forgot to say I must reboot only when I used GDB (with export SAL_NO_MOUSEGRABS=1))
Without gdb, it just crashes
Comment 12 Julien Nabet 2016-12-04 12:13:50 UTC
Created attachment 129298 [details]
bt with symbols

Instead of using "make debugrun", I launched LO as usual then used attaching process (see https://wiki.documentfoundation.org/Development/How_to_debug#Attaching_to_the_soffice.bin_process).
I could retrieve a bt.
It seems to be an infinite recursive loop
Comment 13 Julien Nabet 2016-12-04 12:37:33 UTC
It seems there's a confusion about sqlsubtypes, "decimal" and "numeric"
Reading src/common/dsc.h from Firebird package included in LO:
    445 // Exact numeric subtypes: with ODS >= 10, these apply when dtype
    446 // is short, long, or quad.
    447 
    448 const SSHORT dsc_num_type_none          = 0;    // defined as SMALLINT or INTEGER
    449 const SSHORT dsc_num_type_numeric       = 1;    // defined as NUMERIC(n,m)
    450 const SSHORT dsc_num_type_decimal       = 2;    // defined as DECIMAL(n,m)


In connectivity/source/drivers/firebird/ResultSet.cxx, we can see:
    458         case SQL_SHORT:
    459             if(nSqlSubType == 0 || nSqlSubType == 1) //numeric or decimal
    460                 return getString(nColumnIndex);
    461             return getShort(nColumnIndex);
    462         case SQL_LONG:
    463             if(nSqlSubType == 0 || nSqlSubType == 1) //numeric or decimal
    464                 return getString(nColumnIndex);
    465             return getInt(nColumnIndex);

    468         case SQL_DOUBLE:
    469             if(nSqlSubType == 0 || nSqlSubType == 1) //numeric or decimal
    470                 return getString(nColumnIndex);
    471             return getDouble(nColumnIndex);

    480         case SQL_INT64:
    481             if(nSqlSubType == 0 || nSqlSubType == 1) //numeric or decimal
    482                 return getString(nColumnIndex);
    483             return getLong(nColumnIndex);

so comment doesn't correspond to code.
Whereas this part is ok:
    581     else if ((aSqlType == SQL_SHORT || aSqlType == SQL_LONG
    582                 || aSqlType == SQL_DOUBLE || aSqlType == SQL_INT64)
    583                     && (aSqlSubType == 1 || aSqlSubType == 2))
    584     {
    585         // decimal and numeric types

See http://opengrok.libreoffice.org/xref/core/connectivity/source/drivers/firebird/ResultSet.cxx#459

I gave a try by changing the four:
if(nSqlSubType == 0 || nSqlSubType == 1)

by
if(nSqlSubType == 1 || nSqlSubType == 2)
and I haven't reproduced the crash with it.
Comment 14 Julien Nabet 2016-12-04 12:42:51 UTC
I submitted a patch to review on master here:
https://gerrit.libreoffice.org/#/c/31593/
Comment 15 Commit Notification 2016-12-04 18:23:36 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8d2f58a9922ca7352c626db06f9b8d5ca0bbaead

tdf#104227: fix subtypes DECIMAL/NUMERIC in resultset

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2016-12-04 21:56:15 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d5fc585db2071c57cf9c70f071c8d330ebeca1e4&h=libreoffice-5-3

tdf#104227: fix subtypes DECIMAL/NUMERIC in resultset

It will be available in 5.3.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Julien Nabet 2016-12-04 22:04:58 UTC
Robert: could you please give a new try once the patch will be included in the daily build?
Comment 18 Robert Großkopf 2016-12-07 20:11:26 UTC
Have tested with
Version: 5.4.0.0.alpha0+
Build ID: 63bf040056b64e0bf32a36277c54deee566de4fc
CPU Threads: 4; OS Version: Linux 4.1; UI Render: default; VCL: kde4; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2016-12-06_00:37:50
Locale: de-DE (de_DE.UTF-8); Calc: group

Could confirm the bug has gone with the patch. Thank you, Julien.

I will set this one to RESOLVED and FIXED.
Comment 19 Commit Notification 2016-12-11 10:41:56 UTC
Wastack committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ea61a62323fe398d682da5bbf5b0d9e17d442212

tdf#104227 query boolean like infos correctly

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Julien Nabet 2016-12-14 16:47:28 UTC
Thank you Robert for your feedback, let's put this one to VERIFIED.