Bug 117842 - Firebird: Enabling connection pooling for firebird:sdbc driver crashes Libo when creating connection to data engine
Summary: Firebird: Enabling connection pooling for firebird:sdbc driver crashes Libo w...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
5.4.7.2 release
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:7.3.0 target:7.2.2
Keywords: haveBacktrace
Depends on:
Blocks: Database-Firebird-Default Crash
  Show dependency treegraph
 
Reported: 2018-05-28 04:45 UTC by Drew Jensen
Modified: 2021-09-14 08:27 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
crash dmp file from Libo 5.4.7.2 (467.26 KB, application/vnd.tcpdump.pcap)
2018-05-28 04:46 UTC, Drew Jensen
Details
Crash dmp file from Libo 6.1Beta1 (396.48 KB, application/vnd.tcpdump.pcap)
2018-05-28 04:47 UTC, Drew Jensen
Details
bt with debug symbols (13.29 KB, text/plain)
2018-05-28 20:44 UTC, Julien Nabet
Details
bt from pthread_mutex_lock failed (14.30 KB, text/plain)
2018-05-28 21:06 UTC, Julien Nabet
Details
bt Windows (windbg) (67.85 KB, text/plain)
2019-12-05 16:33 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Drew Jensen 2018-05-28 04:45:10 UTC
Description:
Checked this with 5.4.7.2, 6.0.4, 6.1Beta1, 6.2Alpha0
Crash in all of them
Also checked connection pooling enabled for sdbc.hsql in all of the above, no crash, no problems.

Steps to Reproduce:
1. Open the Options dialog Tools->Options
2. navigate to the Libreoffice Base->Connections section
3. Place a tick mark in 'Enable connection pooling'
4. In the list of drivers select the com.sun.star.comp.sdbc.firebird.Driver
5. Place a tick mark in 'Enable pooling for this Driver' 
6. Accept the default timeout value
7. Click OK to close the options dialog
8. Click Create: New Database
9. Select Firebird Embedded for database type.
10. Click finished, save the new file with some name
10a Alternatively open an ODB file which uses the sdbc.firebird driver or for 6.1 and 6.1 open an ODB file using HSQLdb embedded and allow the migration assistant to start.

Actual Results:  
Crash


Expected Results:
Base file loads and connection to database engine is established.


Reproducible: Always


User Profile Reset: No



Additional Info:


User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
Comment 1 Drew Jensen 2018-05-28 04:46:13 UTC
Created attachment 142322 [details]
crash dmp file from Libo 5.4.7.2
Comment 2 Drew Jensen 2018-05-28 04:47:20 UTC
Created attachment 142323 [details]
Crash dmp file from Libo 6.1Beta1
Comment 3 Julien Nabet 2018-05-28 20:44:28 UTC
Created attachment 142359 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 4 Julien Nabet 2018-05-28 20:59:22 UTC
BTW, I noticed this on console:
warn:legacy.osl:3659:3659:svtools/source/uno/genericunodialog.cxx:288: OGenericUnoDialog::OnDialogDying: where does this come from?
warn:sal.osl.mutex:3659:3659:sal/osl/unx/mutex.cxx:100: pthread_mutex_lock failed: Invalid argument
Comment 5 Julien Nabet 2018-05-28 21:06:06 UTC
Created attachment 142360 [details]
bt from pthread_mutex_lock failed
Comment 6 QA Administrators 2019-06-01 02:49:18 UTC Comment hidden (obsolete)
Comment 7 Alex Thurgood 2019-12-02 11:40:07 UTC
Confirmed bug still present with

Version: 6.3.3.2
Build ID: a64200df03143b798afd1ec74a12ab50359878ed
Threads CPU : 8; OS : Mac OS X 10.14.6; UI Render : par défaut; VCL: osx; 
Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR
Calc: threaded
Comment 8 Julien Nabet 2019-12-05 16:33:18 UTC
Created attachment 156333 [details]
bt Windows (windbg)

On Win10 with master sources updated today, I could still reproduce this.
Comment 9 Julien Nabet 2019-12-05 16:46:36 UTC
weakref + mutex, I can't help here => uncc myself.
Comment 10 Aron Budea 2020-05-17 15:05:09 UTC
No assertion failure mentioned, removing from Assert meta bug.
Comment 11 Mike Kaganski 2021-09-11 10:54:09 UTC
In "normal" case, the XConnection (that gets passed to FirebirdDriver::getDataDefinitionByConnection) is created in OPoolCollection::getConnectionWithInfo using a simple call to xDriver->connect. Given that xDriver is connectivity::firebird::FirebirdDriver, the resulting object is connectivity::firebird::Connection.

In pooling case, OPoolCollection::getConnectionWithInfo takes another branch, and creates the XConnection using a call to pConnectionPool->getConnectionWithInfo, and that ends up in connectivity::OPooledConnection::getConnection, which wraps "m_xRealConnection" (which is the connectivity::firebird::Connection, also obtained from FirebirdDriver) into a connectivity::OConnectionWeakWrapper.

So back in FirebirdDriver::getDataDefinitionByConnection, rConnection (which, as described, may be of different actual classes) is unconditionally cast to connectivity::firebird::Connection. Hence the crash.
Comment 12 Mike Kaganski 2021-09-11 17:25:02 UTC
https://gerrit.libreoffice.org/c/core/+/121890
Comment 13 Commit Notification 2021-09-12 06:03:45 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#117842: use XUnoTunnel to get wrapped connection reliably

It will be available in 7.3.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 14 Commit Notification 2021-09-14 08:27:14 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/19ac6869e129bf03737087eb32198026f9663894

tdf#117842: use XUnoTunnel to get wrapped connection reliably

It will be available in 7.2.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.