Bug 136637 - Firebird: Entering the sql command will cause Libreoffice to hang
Summary: Firebird: Entering the sql command will cause Libreoffice to hang
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.2.0 target:24.8.0.2
Keywords: haveBacktrace
Depends on:
Blocks: Database-Firebird-Default Database-Queries
  Show dependency treegraph
 
Reported: 2020-09-10 06:38 UTC by avsharapov
Modified: 2024-07-23 06:59 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
bt with debug symbols (16.36 KB, text/plain)
2020-09-10 15:48 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description avsharapov 2020-09-10 06:38:59 UTC
Entering the sql command 

CREATE TABLE ext_log EXTERNAL FILE 'ext_log.txt' (c char(2) character set WIN1251)

will cause Libreoffice to hang

Tested on Windows7

P.S. I set the severity to minor because it is unlikely that someone will type such a command :)
Comment 1 Robert Großkopf 2020-09-10 14:31:09 UTC
Seems Firebird doesn't like the character set - definition here.

CREATE TABLE ext_log EXTERNAL FILE 'ext_log.txt' (c char(2));

seems to work with a real path. But I couldn't find the file, which has been created. Then I tried to input values into this (non existent, but listed) table. I will get this message:
firebird_sdbc error:
*Use of external file at location /home/robby/ext_log.txt is not allowed by server configuration
caused by
'INSERT INTO "EXT_LOG" ("C") VALUES ('y');'

All tested under OpenSUSE 15.1 64bit rpm Linux with LO 6.4.6.2

The original command with 
character set WIN1251
leads also to a hang of LO.
Comment 2 Julien Nabet 2020-09-10 15:48:25 UTC
Created attachment 165374 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 3 Julien Nabet 2020-09-10 15:50:20 UTC
Just for the record since, according to the bt, it seems it's Firebird lib itself which aborts, I don't know how we could avoid the crash here.
Comment 4 avsharapov 2020-09-10 16:02:11 UTC
Firebird works well with this command.
And and writes characters in the specified encoding.
But apparently LO can't figure out the meta information later.
Comment 5 avsharapov 2020-09-11 16:02:43 UTC
Please note that my LO fell exactly with the CHARACTER SET option.
Is firebird still relevant? I see that when creating a new database, Firebird is missing from the selection list. This is if advanced mode is not enabled. in 6.3, it was in normal mode.
Comment 6 Robert Großkopf 2020-09-11 16:41:49 UTC
(In reply to shar from comment #5)
> Is firebird still relevant? I see that when creating a new database,
> Firebird is missing from the selection list. This is if advanced mode is not
> enabled. in 6.3, it was in normal mode.

The internal HSQLDB works better with the GUI of base than the internal Firebird. There are many special bugs only for the internal Firebird database. So it has been put back to an experimental feature.
Comment 7 avsharapov 2020-09-12 03:16:24 UTC
I didn't find any information about this in the version change texts. But this is very important. It's a pity that the built-in Firebird is again in question. I considered this a big step and a huge plus for LO Base. But nothing do.
I guess I was too hasty. So I urgently need to do a reverse conversion to Hbase and forget about the built-in Firebird. Thank you for the information.
Comment 8 Thomas Lendo QA 2020-09-12 20:04:35 UTC
For Firebird please see the meta bugs
bug 51780
bug 116968
bug 116970
Comment 9 Julien Nabet 2020-11-28 19:26:35 UTC
(In reply to avsharapov from comment #7)
> I didn't find any information about this in the version change texts. But
> this is very important. It's a pity that the built-in Firebird is again in
> question. I considered this a big step and a huge plus for LO Base. But
> nothing do.
> I guess I was too hasty. So I urgently need to do a reverse conversion to
> Hbase and forget about the built-in Firebird. Thank you for the information.

There's no automatic reverse conversion to HSQLDB. I can only propose you to use backups of your HSQLDB files.
About the lacking information, you're right, it's indeed lacking in release notes. (I put tdf#135882 on cc).
Comment 10 QA Administrators 2022-11-29 03:43:38 UTC Comment hidden (obsolete)
Comment 11 Robert Großkopf 2022-11-29 07:51:55 UTC
Bug still exists with LO 7.4.3.2 on OpenSUSE 15.3 64bit rpm Linux.
Comment 12 Mike Kaganski 2024-07-20 09:53:39 UTC
This issue combined two different problems.

1. Hang/crash.
2. Missing intl (charset/collation) data. We simply do not bundle anything needed by embedded Firebird, except ifbclient.dll and Engine12.dll; so we don't e.g. bundle intl/ with its fbintl.conf and fbintl.dll, so we only have a handful of embedded charsets, no WIN1251.

I will address the first here, and file the other one separately.
Comment 13 Mike Kaganski 2024-07-20 09:58:24 UTC
https://gerrit.libreoffice.org/c/core/+/170790
Comment 14 Mike Kaganski 2024-07-20 10:02:39 UTC
Note that testing on Linux is irrelevant for both issues here *at this stage*, because on Linux, likely a system Firebird is used; and there, neither crash nor missing intl data happen. What we see there is likely the next stage, when we will fix the first part specific to Windows (no idea if TDF build for Linux is affected). Then we will see if/why the *succeeded* DDL command results in following failures, as shown in comment 1.
Comment 15 Commit Notification 2024-07-20 14:43:15 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1edfbb310889d18cdd19aa8b339a510ffb25cf66

tdf#136637: handle SQLException in OStatementBase::disposing

It will be available in 25.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 16 Mike Kaganski 2024-07-21 16:57:48 UTC
After this hang/crash problem is saved, as well as bug 162115 about missing intl data, it is possible to execute:

 CREATE TABLE mytable (c char(2) character set WIN1251)

It is still impossible to create external file tables, exactly because of the missing "server" configuration permission, as noted in comment 1 on Linux. If needed, you can file a separate bug report for that issue (now common for all platforms).

Note that this is controlled by ExternalFileAccess setting in an optional firebird.conf file; its template is available if FB repo [1].

Note the text in the setting explanation:

# NOTE: THE EXTERNAL TABLE ENGINE FEATURE COULD BE USED TO COMPROMISE
# THE SERVER/HOST AS WELL AS DATABASE SECURITY!!
#
# IT IS STRONGLY RECOMMENDED THAT THIS SETTING BE USED TO LIMIT
# EXTERNAL TABLE LOCATIONS!

To me, it is unclear if we should somehow expose this functionality in LibreOffice. But of course, depends on the use case and extent of demand.

[1] https://github.com/FirebirdSQL/firebird/blob/master/builds/install/misc/firebird.conf
Comment 17 jcsanz 2024-07-21 21:09:11 UTC
(In reply to Mike Kaganski from comment #16)

> It is still impossible to create external file tables, exactly because of
> the missing "server" configuration permission, as noted in comment 1 on
> Linux. If needed, you can file a separate bug report for that issue (now
> common for all platforms).
> 
> Note that this is controlled by ExternalFileAccess setting in an optional
> firebird.conf file; its template is available if FB repo [1].
> 


This can be bypassed just creating the firebird.conf in the program folder and configuring ExternalFileAccess = Full 

> To me, it is unclear if we should somehow expose this functionality in
> LibreOffice. But of course, depends on the use case and extent of demand.
> 

I don't think we should expose it. If somebody with the knowledge need it, only need to add and configure the firebird.conf file, and if don't have the knowledge, is better not to make it easy for them to configure and break something.
Comment 18 Commit Notification 2024-07-23 06:59:48 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/c245557c4e99ec77c40f493cf7658c1ee0f7eefe

tdf#136637: handle SQLException in OStatementBase::disposing

It will be available in 24.8.0.2.

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

Affected users are encouraged to test the fix and report feedback.