Bug 96914 - MAILMERGE crash on first run after DB registration
Summary: MAILMERGE crash on first run after DB registration
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.1.0.1 rc
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.2.0
Keywords: bisected, regression
: 100299 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-01-06 01:34 UTC by Jan-Marek Glogowski
Modified: 2016-10-25 19:02 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Backtrace when closing libreoffice-5-0 build (7.33 KB, text/plain)
2016-01-06 01:46 UTC, Jan-Marek Glogowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Marek Glogowski 2016-01-06 01:34:03 UTC
I'm using the documents attached to bug 93565 for my test.
Actually I found the crash when debugging and fixing it.

Steps to reproduce:
 1. Open the odt
 2. Register the ods as the database using the MM wizard step 3 using the
    "Select different address list" button. Then cancel the wizard.
    This way the DB is registered as an EmbeddedDatabase.
 3. Run a mail merge via File => Print ...
 4. Observe the crash

The crash doesn't happen the 2nd time with an already registered DB.

The crashing state can be easily restored by opening the "data sources" (F4) -> Right click -> "registered databases..." -> delete the database "1247_TabAttestati", or removing the user profile.

For me the crash happens in line 
  ~/Development/libreoffice/symbols/sw/source/uibase/dbui/dbmgr.cxx:1040

nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;

bibisecting resulted in:
 git log 9f01951b858453684f2622541af0eb85d4544fc6~1..8ae25bbc092254f680e2976873f15bdbc26615ef

git log --pretty=oneline 9f01951b858453684f2622541af0eb85d4544fc6~1..8ae25bbc092254f680e2976873f15bdbc26615ef sw
 d611b2e0b2b713ffaf8b2ec75e6a74180316f50b sw: add SwDBManager::RevokeDataSource() b79017f49a487a3981b1cd9f488ed5062eeb880b sw: move name of the embedded data source def from SwDBData to SwDBManager 9eb16c85d6af4b73de9a75716c3ff34f929f26b2 don't crash on layout of ooo55381-1.sxw 77df4faa4783df38383020a6236136a88eb51069 fix crash on export of ooo39845-7.sxw to .docx cf7439c5510578572b30a92a52549b5babfa93d9 SwDBManager: store of embedded data source definition is implemented c61065b262051e510ab5229a8f10efc10962137f SwAddressListDialog::LoadHdl_Impl: simplify 9d0c6308be5fb086e51cb8b4b0652f3d6184fd3c fix crash on export of ooo34469-1.sxw to docx 8d2fe8d7e5f374f3a106a4fc58ef597a52815ad0 SwView::SearchAndWrap: fix WrapAround search in fly frames 21a6b99748db8a970ef7dc90d40e07901135b89a tdf#91781 Fix some entry headings 9f01951b858453684f2622541af0eb85d4544fc6 tdf#91228 Fix Writer crash

so it's probably "embedded database" related
Comment 1 Jan-Marek Glogowski 2016-01-06 01:37:24 UTC
BTW: the crash is actually an uncaught exception somewhere down in pImpl->pMergeData->xResultSet->getRow()
Comment 2 Jan-Marek Glogowski 2016-01-06 01:46:24 UTC
Created attachment 121742 [details]
Backtrace when closing libreoffice-5-0 build

Might be related or not.
LO 5.0 doesn't crash but shows the attached BT on close after the MM.
Comment 3 Jan-Marek Glogowski 2016-01-21 13:35:36 UTC
I don't understand, why it crashes, but here is the test case:

1. Have a document with MM fields but no embedded DB
1.1 Deregister the DB of the fields, if it is already registered
    (F4, Right Click, Registered DBs... , Delete DB)
2. Register the DB via MM Wizard
   (Go to step three and select the datasource)
  => The DB is registered as an embedded DB.
3. Cancel the Wizard
4 Use File -> Print... -> MM
5. Run any MM with the DB from this document
6. Crash, as an Exception from

The actual crash is the DisposedException() from
   ::connectivity::checkDisposed(m_rBHelper.bDisposed);
in void ORowSetBase::checkCache()

"Fun" facts: 
 * If you open a second document with MM fields from the same DB, no crash
 * If you reopen the MM wizard and use the DB, no crash
 * If you save and load the document, no crash
Comment 4 Jan-Marek Glogowski 2016-01-21 21:07:39 UTC
Ok - now finally I have found the origin of the problem and it's much worse :-( You can't merge any document with embedded databases via File -> Print.

Workflow of SwDBManager::ExecuteFormLetter is:
 1. Open dialog
 2. Get XResultSet
 3. Save document
 4. Load saved document
   => disposes XResultSet, as we have a 2nd embedded DB with the same name.
 5. Bad things happen.

This is a more general problem.

And SwDBManager::ExecuteFormLetter should use an internal clone instead of a load save cycle.
Comment 5 Yousuf Philips (jay) (retired) 2016-03-02 20:39:58 UTC
Just going to set this to NEW as its you jmux. :D
Comment 7 Robinson Tryon (qubit) 2016-05-12 04:40:12 UTC
TESTING with
LO 5.2.0.0.alpha1+
OS Version: Mac OS X 10.10.5
Build: 2016-05-11_01:01:27

(In reply to Jan-Marek Glogowski from comment #3)
> I don't understand, why it crashes, but here is the test case:
> 

Repro Steps:

> 1. Have a document with MM fields but no embedded DB

- Nab the test docs from bug 95293 (attachment 121094 [details])
- Open 'serial_letter_TDF_95293.fodt'

> 1.1 Deregister the DB of the fields, if it is already registered
>     (F4, Right Click, Registered DBs... , Delete DB)

Hmm...not sure that works on OSX. I tried:
 
- LibreOfficeDev -> Preferences -> LibreOfficeDev Base -> Databases

I then selected the db entry and clicked (Delete)

> 2. Register the DB via MM Wizard
>    (Go to step three and select the datasource)

- Tools -> MM Wizard -> (etc...)
- I selected 'Tabelle1'
- I stopped immediately after *registering* the Address List

>   => The DB is registered as an embedded DB.

> 3. Cancel the Wizard
> 4 Use File -> Print... -> MM
> 5. Run any MM with the DB from this document

Choosing File -> Print, I'm prompted to print a form letter;
Clicking (OK), I can then chose 'Print'; for printer I clicked on the 'PDF' drop-down and Saved As PDF (name: 'Output_96914')

> 6. Crash, as an Exception from
> 
> The actual crash is the DisposedException() from
>    ::connectivity::checkDisposed(m_rBHelper.bDisposed);
> in void ORowSetBase::checkCache()

NO REPRO. PDF was saved as expected.

I then tried clicking directly on the 'Print Merged Documents' button in the mail merge toolbar, and again no crash occurred.

Jan-Marek: What's the current status here?
Comment 8 Jan-Marek Glogowski 2016-05-23 14:12:44 UTC
This bug should have been fixed with the commit in comment #6:
> https://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=aeb01b75e56916bf36707ad703a16c90ad7f2419

And as Robinson proved, it really seems to be fixed :-)
Comment 9 Caolán McNamara 2016-06-15 14:17:58 UTC
*** Bug 100299 has been marked as a duplicate of this bug. ***