Bug 169541 - Crash in: Data Provider: import 2x + save = crash on open file
Summary: Crash in: Data Provider: import 2x + save = crash on open file
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.8.2.2 release
Hardware: All All
: high critical
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0 target:25.8.4
Keywords: haveBacktrace
Depends on:
Blocks: Data-Provider
  Show dependency treegraph
 
Reported: 2025-11-19 16:34 UTC by Michael Otto
Modified: 2025-11-27 11:43 UTC (History)
2 users (show)

See Also:
Crash report or crash signature: ["<name omitted>"]


Attachments
Data Provider used 2x and save (10.00 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-11-19 16:34 UTC, Michael Otto
Details
simple 3 lines CSV file (27 bytes, text/csv)
2025-11-19 16:35 UTC, Michael Otto
Details
another example with several Data Provider operations (50.68 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-11-20 09:55 UTC, Michael Otto
Details
GDB trace of crash (9.74 KB, text/plain)
2025-11-23 16:59 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Otto 2025-11-19 16:34:46 UTC
Created attachment 204100 [details]
Data Provider used 2x and save

This bug was filed from the crash reporting server and is br-1d145b40-e65b-48d0-954d-5aba6c7ffa5f.
=========================================

PRECONDITION:
new Calc spreadsheet, Data > Define Range 
(see Bug #169514 attachment DataRangeForDataProvider.ods)
https://bugs.documentfoundation.org/attachment.cgi?id=204066


PROBLEM DESCRIPTION:
Data > Data Provider
  select Range, CSV, URL=attached abc123.csv 
  OK to import data
do this another time: Data > Data Provider
  select Range, CSV, URL=attached abc123.csv 
  OK to import data
save file (see attaced "Data Provider used 2x and save")
open file --> LO aborts

this is reproducible

abc123.csv is simply this:
a1,a2,a3
b1,b2,b3
c1,c2,c3


N.B.:
if Data Provider is used multiple times,
content.xml contains multiple identical of theses elements
(when removing all but 1 by text editor, there is no crash on open file):

<calcext:data-mapping xlink:href="file:///home/micha/LibreOffice/bugreports/abc123.csv" calcext:provider="org.libreoffice.calc.csv" calcext:frequency="0" calcext:id="org.libreoffice.calc.csv" calcext:database-name="Neue_Datenbank">
<calcext:data-transformations/>
</calcext:data-mapping>


Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 480ef73deef62c458e5735cd496a1d74ef408ed8
CPU threads: 2; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded
Comment 1 Michael Otto 2025-11-19 16:35:34 UTC
Created attachment 204101 [details]
simple 3 lines CSV file
Comment 2 Michael Otto 2025-11-20 09:55:11 UTC
Created attachment 204129 [details]
another example with several Data Provider operations

if after several Data Provider operations
a File > Reload is done, there is also a crash, see
https://crashreport.libreoffice.org/stats/crash_details/b02e80cc-31f8-42aa-b78f-92f1f9bf8620
Comment 3 jcline 2025-11-22 03:15:50 UTC
repro in Version: 25.8.2.2 (X86_64)
Build ID: d401f2107ccab8f924a8e2df40f573aab7605b6f
CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

and Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 620(Build:0)
CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 4 Buovjaga 2025-11-23 16:59:27 UTC
Created attachment 204230 [details]
GDB trace of crash

Trace of crash when opening attachment 204100 [details]
Comment 5 Regina Henschel 2025-11-23 19:27:17 UTC
It crashes in the same way, if the <calcext:data-mapping> elements use different csv sources and different database ranges. And that would be a legitimate use of the "Data Provider" feature.

Somewhere the sc::ExternalDataSource element lost the URL.

There is something wrong with ScXMLMappingContext, because I get its dtor two times, in the first call with 1 element in rDataSources and in the second call with 2 elements in rDataSources. If I delete the refreshed item from rDataSources, it does no longer crash. But that is no solution, because then the link to the csv-file is lost and command "Refresh Data Provider" is not possible.
Comment 6 Regina Henschel 2025-11-23 19:54:38 UTC
Changing rDataSources[0] to rDataSources.back() in
https://opengrok.libreoffice.org/xref/core/sc/source/filter/xml/xmlmappingi.cxx?r=6b3089df68caed32e4fba981ffa3e33c74fbb515#120

makes that the file opens without crash.

But then "Refresh Data Provider" crashes :(
Comment 7 Regina Henschel 2025-11-24 11:12:06 UTC
My suggestion for a fix is now in https://gerrit.libreoffice.org/c/core/+/194433.
Comment 8 Commit Notification 2025-11-27 10:42:10 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

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

tdf#169541 DataProvider avoid corrupt backreference

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 9 Commit Notification 2025-11-27 11:43:18 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/39948910b829d6ce93dd8fbc89095a3f772df0e9

tdf#169541 DataProvider avoid corrupt backreference

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.