Bug 99619 - query design segfault on redoing an undone table join creation
Summary: query design segfault on redoing an undone table join creation
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium major
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0 target:25.8.4
Keywords: haveBacktrace
Depends on:
Blocks: Undo-Redo Database-Queries Crash
  Show dependency treegraph
 
Reported: 2016-05-02 01:20 UTC by tadanet3
Modified: 2025-11-21 06:28 UTC (History)
8 users (show)

See Also:
Crash report or crash signature: ["dbaui::OTableConnection::InvalidateConnection()"]


Attachments
procedure (630.96 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-05-02 01:20 UTC, tadanet3
Details
bt with symbols (4.98 KB, text/plain)
2016-05-02 21:47 UTC, Julien Nabet
Details
bt with debug symbols (5.83 KB, text/plain)
2018-01-26 11:52 UTC, Julien Nabet
Details
bt with debug symbols (6.31 KB, text/plain)
2020-05-22 09:32 UTC, Julien Nabet
Details
Valgrind trace (28.62 KB, application/x-bzip)
2020-05-22 11:27 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tadanet3 2016-05-02 01:20:27 UTC
Created attachment 124775 [details]
procedure

Hellow,

I use LibreOffice_5.1.2_Win_x86.msi, Win7 SP1

on Base 
1.Create database
2.Create table
3.Insert join
4.Undo
5.Redo
6.Crash

For more detaile procedurr, please see the attached file
Comment 1 raal 2016-05-02 06:56:53 UTC
I can confirm with Version: 5.2.0.0.alpha0+ and 4.0; win7
Comment 2 Julien Nabet 2016-05-02 21:47:14 UTC
Created attachment 124801 [details]
bt with symbols

On pc Debian x86-64 with master sources updated today, I had a crash when I tried to a create the join at the beginning.
Comment 3 Julien Nabet 2016-05-02 22:12:58 UTC
I tried to understand the problem of bt I had and noticed this new bt:
#0  com::sun::star::uno::BaseReference::iquery (pInterface=0x2bacd08, rType=invalid uno::Type) at /home/julien/lo/libreoffice/include/com/sun/star/uno/Reference.hxx:54
#1  0x00002aaad9c3cd18 in com::sun::star::uno::Reference<com::sun::star::lang::XUnoTunnel>::iquery (pInterface=0x2bacd08)
    at /home/julien/lo/libreoffice/include/com/sun/star/uno/Reference.hxx:69
#2  0x00002aaad9c39fa5 in com::sun::star::uno::Reference<com::sun::star::lang::XUnoTunnel>::Reference (this=0x7fffffff3a90, rRef=...)
    at /home/julien/lo/libreoffice/include/com/sun/star/uno/Reference.hxx:170
#3  0x00002aaad9e127c6 in dbaui::OJoinExchObj::GetSourceDescription (_rxObject=uno::Reference to (GtkDnDTransferable *) 0x2bacd08)
    at /home/julien/lo/libreoffice/dbaccess/source/ui/querydesign/JoinExchange.cxx:76
#4  0x00002aaad9ea2330 in dbaui::OTableWindowListBox::ExecuteDrop (this=0x3f66cc0, _rEvt=...)
    at /home/julien/lo/libreoffice/dbaccess/source/ui/querydesign/TableWindowListBox.cxx:308

Stephan: any thoughts?
(openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-2-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
)
Comment 4 Stephan Bergmann 2016-05-03 07:36:35 UTC
(In reply to Julien Nabet from comment #3)
> Stephan: any thoughts?

Smells like _rEvt.maDropEvent.Transferable in frame #4 is already corrupted.
Comment 5 Xisco Faulí 2017-02-27 17:10:55 UTC
Also reproduced in

Version: 5.3.0.3
Build ID: 1:5.3.0~rc3-0ubuntu1~yakkety1.1
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk3; Layout Engine: new; 
Locale: es-ES (ca_ES.UTF-8); Calc: group
Comment 6 Julien Nabet 2018-01-26 11:52:53 UTC
Created attachment 139372 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated some days ago, I could reproduce this.
Since the bt is different, I attach a new one.
Comment 7 QA Administrators 2019-06-15 02:58:49 UTC Comment hidden (obsolete)
Comment 8 Xisco Faulí 2020-05-22 08:27:13 UTC
@Lionel, I thought you might be interested in this issue
Comment 9 Lionel Elie Mamane 2020-05-22 08:53:14 UTC
Does this happen also with joins on two different tables, or only in the "join the table to itself" case that the original bug reporter was showing in attachment 124775 [details]?
Comment 10 Julien Nabet 2020-05-22 09:29:43 UTC
(In reply to Lionel Elie Mamane from comment #9)
> Does this happen also with joins on two different tables, or only in the
> "join the table to itself" case that the original bug reporter was showing
> in attachment 124775 [details]?

In brief, yes
In detail:
on pc Debian x86-64 with master sources updated today, here are the steps I did:
- create brand new odb embedded HSQLDB file
- create ORDERS and CUSTOMERS table with wizard (I kept by default options for both).
- create a new Query with Design
- add both tables
- insert join between ORDERS.CUSTOMER_ID and CUSTOMERS.ID
- undo
- redo
=> crash
Comment 11 Julien Nabet 2020-05-22 09:32:10 UTC
Created attachment 161125 [details]
bt with debug symbols

Just to update the bt but it seems quite the same.
Comment 12 Julien Nabet 2020-05-22 11:27:19 UTC
Created attachment 161135 [details]
Valgrind trace

If it may help...
Comment 13 QA Administrators 2022-05-23 03:37:43 UTC Comment hidden (obsolete)
Comment 14 Robert Großkopf 2022-05-23 06:22:06 UTC
Took description of comment 10.

Crash could be reproduced with internal HSQLDB and also internal Firebird on OpenSUSE 15.3 with

Version: 7.3.4.1 / LibreOffice Community
Build ID: 13668373362b52f6e3ebcaaecb031bd59a3ac66b
CPU threads: 6; OS: Linux 5.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded
Comment 15 Stéphane Guillou (stragu) 2024-04-30 02:46:14 UTC
Still reproduced following comment 10 steps with:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 2f5ab5b8e7bd7dd06e00153abb77a69e5d192dd2
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: CL threaded

Crash report for 24.2: https://crashreport.libreoffice.org/stats/crash_details/0b9d870f-96da-417b-b504-eec845a0ae17
Comment 16 Neil Roberts 2025-11-10 10:56:09 UTC
I think what is happening is this:

Internally, the join is called a connection and is stored in an OQueryTableConnection. When a connection is added an OQueryAddTabConnUndoAction is created to record the undo action. When the action is undone, OQueryAddTabConnUndoAction calls OQueryTableView::DropConnection which calls OQueryTableView::RemoveConnection. That in turn tries to add another undo action to allow undoing the remove. This second undo object is marked as “owning” the OQueryTableConnection. The second undo object is blocked from being added to the undo manager because SfxUndoManager::mbUndoEnabled is set to false while an undo operation is taking place. When the undo operation is finished being applied this second undo operation is instead immediately deleted. However, because it thinks it owns the OQueryTableConnection it calls dispose on it which makes it no longer have a window pointer. The first undo operation then marks itself as owning the connection. When the redo button is pressed, the “add connection” operation is redone but it crashes when it tries to access the null window pointer.

You can also trigger the bug if you delete the join with the delete key and then press undo, redo, undo.

I made a UI test case to trigger the bug and I’m trying to think of the best way to fix it.
Comment 17 Commit Notification 2025-11-11 05:47:33 UTC
Neil Roberts committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2dde26dcaee48d37a508617515addce634d0c96c

tdf#99619 Don’t add undo action when removing conn but not deleting

It will be available in 26.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 18 Commit Notification 2025-11-11 05:47:36 UTC
Neil Roberts committed a patch related to this issue.
It has been pushed to "master":

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

tdf#99619 Add a UI test

It will be available in 26.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 19 Commit Notification 2025-11-11 09:06:11 UTC
Neil Roberts committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/3a681cf1498da6ffba430cd06192290b8c5e2251

tdf#99619 Don’t add undo action when removing conn but not deleting

It will be available in 25.8.4.

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 20 Commit Notification 2025-11-21 06:28:15 UTC
Neil Roberts committed a patch related to this issue.
It has been pushed to "master":

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

UITest/tdf99619: Close the query window at the end of the test

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