office-gobmx/sc
Noel Grandin cacd5a0cd2 attempted fix for CppunitTest_sc_uicalc
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior include/svl/setitem.hxx:47:51 in
=================================================================
==357324==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c001c9c340 at pc 0x7fa4bb883389 bp 0x7ffc2482f5f0 sp 0x7ffc2482f5e8
READ of size 2 at 0x60c001c9c340 thread T0
    #1 in SfxItemSet::Get(unsigned short, bool) const svl/source/items/itemset.cxx:801:26
    #2 in SfxUInt32Item const& SfxItemSet::Get<SfxUInt32Item>(TypedWhichId<SfxUInt32Item>, bool) const include/svl/itemset.hxx:102:38
    #3 in (anonymous namespace)::getNumberFormatKey(SfxItemSet const&) sc/source/core/data/patattr.cxx:1291:17
    #4 in ScPatternAttr::GetNumberFormat(SvNumberFormatter*, SfxItemSet const*) const sc/source/core/data/patattr.cxx:1335:19
    #5 in ScColumn::UpdateScriptType() sc/source/core/data/column3.cxx:871:36
    #6 in ScColumn::GetRangeScriptType(...) sc/source/core/data/column2.cxx:2338:17
    #7 in ScTable::GetRangeScriptType(sc::ColumnBlockPosition&, short, int, int) sc/source/core/data/table1.cxx:2487:23
    #8 in ScDocument::GetRangeScriptType(sc::ColumnBlockPosition&, ScAddress const&, int) sc/source/core/data/documen6.cxx:189:32
    #9 in (anonymous namespace)::ScriptTypeAggregator::execute(ScAddress const&, int, bool) sc/source/core/data/documen6.cxx:175:31
    #10 in sc::ColumnSpanSet::executeAction(ScDocument&, sc::ColumnSpanSet::Action&) const sc/source/core/data/columnspanset.cxx:176:20
    #11 in ScDocument::GetRangeScriptType(ScRangeList const&) sc/source/core/data/documen6.cxx:206:10
    #12 in ScViewFunc::GetSelectionScriptType() sc/source/ui/view/viewfunc.cxx:898:24
    #13 in ScFormatShell::GetAttrState(SfxItemSet&) sc/source/ui/view/formatsh.cxx:2001:34
    ...
    #61 in main2() sal/cppunittester/cppunittester.cxx:483:16

0x60c001c9c340 is located 64 bytes inside of 120-byte region [0x60c001c9c300,0x60c001c9c378)
freed by thread T0 here:
    #0 in operator delete(void*, unsigned long) /home/noel/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:164:3
    #1 in ScPatternAttr::~ScPatternAttr() sc/inc/patattr.hxx:53:20
    #2 in SfxItemPool::Remove(SfxPoolItem const&) svl/source/items/itempool.cxx:805:13
    #3 in ScAttrArray::SetPatternAreaImpl(int, int, ScPatternAttr const*, bool, ScEditDataArray*, bool) sc/source/core/data/attarray.cxx:574:31
    #4 in ScAttrArray::SetPattern(int, ScPatternAttr const*, bool) sc/inc/attarray.hxx:148:7
    #5 in ScColumn::ApplyAttr(int, SfxPoolItem const&) sc/source/core/data/column.cxx:633:21
    #6 in ScColumn::SetNumberFormat(int, unsigned int) sc/source/core/data/column2.cxx:3282:5
    #7 in ScTable::SetNumberFormat(short, int, unsigned int) sc/source/core/data/table2.cxx:2278:35
    #8 in ScDocument::SetNumberFormat(ScAddress const&, unsigned int) sc/source/core/data/document.cxx:3739:19
    #9 in ScFormulaCell::InterpretTail(ScInterpreterContext&, ScFormulaCell::ScInterpretTailParameter) sc/source/core/data/formulacell.cxx:2157:31
    #10 in ScFormulaCell::Interpret(int, int) sc/source/core/data/formulacell.cxx:1619:13
    #11 in ScFormulaCell::MaybeInterpret() sc/inc/formulacell.hxx:468:17
    #12 in ScFormulaCell::IsValue() sc/source/core/data/formulacell.cxx:2760:5
    #13 in lcl_GetCellContent(ScRefCellValue&, bool, double&, rtl::OUString&, ScDocument const*) sc/source/core/data/conditio.cxx:744:40
    #14 in ScConditionEntry::IsCellValid(ScRefCellValue&, ScAddress const&) const sc/source/core/data/conditio.cxx:1243:17
    #15 in ScConditionalFormat::GetCellStyle(ScRefCellValue&, ScAddress const&) const sc/source/core/data/conditio.cxx:1812:24
    #16 in ScDocument::GetCondResult(ScRefCellValue&, ScAddress const&, ScConditionalFormatList const&, o3tl::sorted_vector<unsigned int, std::less<unsigned int>, o3tl::find_unique, true> const&) const sc/source/core/data/documen4.cxx:828:41
    #17 in ScColumn::UpdateScriptType(sc::CellTextAttr&, int, mdds::mtv::soa::detail::iterator_base<mdds::mtv::soa::multi_type_vector<sc::CellStoreTraits>::iterator_trait>&) sc/source/core/data/column3.cxx:865:30
    #18 in ScColumn::GetRangeScriptType(int, mdds::mtv::soa::detail::iterator_base<mdds::mtv::soa::multi_type_vector<sc::CellStoreTraits>::iterator_trait> const&) sc/source/core/data/column2.cxx:2338:17
    #19 in ScTable::GetRangeScriptType(sc::ColumnBlockPosition&, short, int, int)
        sc/source/core/data/table1.cxx:2487:23

previously allocated by thread T60 here:
    #0 in operator new(unsigned long) /home/noel/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
    #1 in ScAttrArray::AddCondFormat(int, int, unsigned int)
       sc/source/core/data/attarray.cxx:296:32
    #2 in ScColumn::AddCondFormat(int, int, unsigned int)
       sc/inc/column.hxx:974:17
    #3 in ScTable::AddCondFormatData(ScRangeList const&, unsigned int)
       sc/source/core/data/table2.cxx:2967:43
    #4 in ScDocument::AddCondFormatData(ScRangeList const&, short, unsigned int)
       sc/source/core/data/document.cxx:4893:19
    #5 in oox::xls::CondFormat::finalizeImport()
       sc/source/filter/oox/condformatbuffer.cxx:1065:10
    #6 in oox::xls::CondFormatBuffer::finalizeImport()
       sc/source/filter/oox/condformatbuffer.cxx:1189:27
    #7 in oox::xls::WorksheetGlobals::finalizeWorksheetImport()
       sc/source/filter/oox/worksheethelper.cxx:942:22
    #8 in oox::xls::WorksheetHelper::finalizeWorksheetImport()
       sc/source/filter/oox/worksheethelper.cxx:1622:17
    #9 in oox::xls::WorksheetFragment::finalizeImport()
       sc/source/filter/oox/worksheetfragment.cxx:632:5
    #10 0x7fa4511cbf2a in oox::core::FragmentHandler2::endDocument()
       oox/source/core/fragmenthandler2.cxx:53:5

Change-Id: I8d806fd410d1d3a9c06ab141b035153649cf7062
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147513
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-23 15:52:29 +00:00
..
inc attempted fix for CppunitTest_sc_uicalc 2023-02-23 15:52:29 +00:00
qa tdf#153767: sc_subsequent_filters_test2: Add unittest 2023-02-23 13:19:29 +00:00
res/xml
sdi tdf#63965 Hide one extra Rename Sheet command from Customize dialog 2023-02-22 13:32:03 +00:00
source attempted fix for CppunitTest_sc_uicalc 2023-02-23 15:52:29 +00:00
uiconfig/scalc gtk[3|4] drop can-focus so it takes the default state 2023-02-01 13:54:27 +00:00
util
workben
AllLangMoTarget_sc.mk
common_unoapi_tests.mk
CppunitTest_sc_a11y.mk
CppunitTest_sc_addin_functions_test.mk
CppunitTest_sc_anchor_test.mk
CppunitTest_sc_annotationobj.mk
CppunitTest_sc_annotationshapeobj.mk
CppunitTest_sc_annotationsobj.mk
CppunitTest_sc_arealinkobj.mk
CppunitTest_sc_arealinksobj.mk
CppunitTest_sc_array_functions_test.mk
CppunitTest_sc_autoformatobj.mk
CppunitTest_sc_autoformatsobj.mk
CppunitTest_sc_bugfix_test.mk
CppunitTest_sc_cache_test.mk
CppunitTest_sc_cellcursorobj.mk
CppunitTest_sc_cellfieldsobj.mk
CppunitTest_sc_cellformatsenumeration.mk
CppunitTest_sc_cellformatsobj.mk
CppunitTest_sc_cellobj.mk
CppunitTest_sc_cellrangeobj.mk
CppunitTest_sc_cellrangesobj.mk
CppunitTest_sc_cellsearchobj.mk
CppunitTest_sc_cellsenumeration.mk
CppunitTest_sc_cellsobj.mk
CppunitTest_sc_chart2dataprovider.mk
CppunitTest_sc_chartobj.mk
CppunitTest_sc_chartsobj.mk
CppunitTest_sc_check_data_pilot_field.mk
CppunitTest_sc_check_data_pilot_table.mk
CppunitTest_sc_check_xcell_ranges_query.mk
CppunitTest_sc_cond_format_merge.mk
CppunitTest_sc_consolidationdescriptorobj.mk
CppunitTest_sc_copypaste.mk
CppunitTest_sc_core.mk
CppunitTest_sc_database_functions_test.mk
CppunitTest_sc_databaserangeobj.mk
CppunitTest_sc_databaserangesobj.mk
CppunitTest_sc_datapilotfieldgroupitemobj.mk
CppunitTest_sc_datapilotfieldgroupobj.mk
CppunitTest_sc_datapilotfieldgroupsobj.mk
CppunitTest_sc_datapilotfieldobj.mk
CppunitTest_sc_datapilotfieldsobj.mk
CppunitTest_sc_datapilotitemobj.mk
CppunitTest_sc_datapilotitemsobj.mk
CppunitTest_sc_datapilottableobj.mk
CppunitTest_sc_datapilottablesobj.mk
CppunitTest_sc_dataprovider.mk
CppunitTest_sc_datetime_functions_test.mk
CppunitTest_sc_ddelinkobj.mk
CppunitTest_sc_ddelinksobj.mk
CppunitTest_sc_documentconfigurationobj.mk
CppunitTest_sc_drawpageobj.mk
CppunitTest_sc_drawpagesobj.mk
CppunitTest_sc_editfieldobj_cell.mk
CppunitTest_sc_editfieldobj_header.mk
CppunitTest_sc_filterdescriptorbase.mk
CppunitTest_sc_filters_test.mk
CppunitTest_sc_financial_functions_test.mk
CppunitTest_sc_functiondescriptionobj.mk
CppunitTest_sc_functionlistobj.mk
CppunitTest_sc_functions_test_old.mk
CppunitTest_sc_headerfieldsobj.mk
CppunitTest_sc_headerfootercontentobj.mk
CppunitTest_sc_html_export_test.mk
CppunitTest_sc_importdescriptorbaseobj.mk
CppunitTest_sc_indexenumeration_cellannotationsenumeration.mk
CppunitTest_sc_indexenumeration_cellarealinksenumeration.mk
CppunitTest_sc_indexenumeration_databaserangesenumeration.mk
CppunitTest_sc_indexenumeration_datapilotfieldsenumeration.mk
CppunitTest_sc_indexenumeration_datapilotitemsenumeration.mk
CppunitTest_sc_indexenumeration_datapilottablesenumeration.mk
CppunitTest_sc_indexenumeration_ddelinksenumeration.mk
CppunitTest_sc_indexenumeration_functiondescriptionenumeration.mk
CppunitTest_sc_indexenumeration_labelrangesenumeration.mk
CppunitTest_sc_indexenumeration_namedrangesenumeration.mk
CppunitTest_sc_indexenumeration_scenariosenumeration.mk
CppunitTest_sc_indexenumeration_sheetcellrangesenumeration.mk
CppunitTest_sc_indexenumeration_sheetlinksenumeration.mk
CppunitTest_sc_indexenumeration_spreadsheetsenumeration.mk
CppunitTest_sc_indexenumeration_spreadsheetviewpanesenumeration.mk
CppunitTest_sc_indexenumeration_subtotalfieldsenumeration.mk
CppunitTest_sc_indexenumeration_tableautoformatenumeration.mk
CppunitTest_sc_indexenumeration_tablechartsenumeration.mk
CppunitTest_sc_indexenumeration_tablecolumnsenumeration.mk
CppunitTest_sc_indexenumeration_tableconditionalentryenumeration.mk
CppunitTest_sc_indexenumeration_tablerowsenumeration.mk
CppunitTest_sc_indexenumeration_textfieldenumeration.mk
CppunitTest_sc_information_functions_test.mk
CppunitTest_sc_jumbosheets_test.mk
CppunitTest_sc_labelrangeobj.mk
CppunitTest_sc_labelrangesobj.mk
CppunitTest_sc_logical_functions_test.mk
CppunitTest_sc_macros_test.mk
CppunitTest_sc_mark_test.mk
CppunitTest_sc_mathematical_functions_test.mk
CppunitTest_sc_modelobj.mk
CppunitTest_sc_namedrangeobj.mk
CppunitTest_sc_namedrangesobj.mk
CppunitTest_sc_new_cond_format_api.mk
CppunitTest_sc_opencl-1.mk Split long-running CppunitTest_sc_opencl_test in two 2023-01-27 14:28:34 +00:00
CppunitTest_sc_opencl-2.mk Split long-running CppunitTest_sc_opencl_test in two 2023-01-27 14:28:34 +00:00
CppunitTest_sc_outlineobj.mk
CppunitTest_sc_pdf_export.mk
CppunitTest_sc_perfobj.mk
CppunitTest_sc_pivottable_filters_test.mk
CppunitTest_sc_recentfunctionsobj.mk
CppunitTest_sc_recordchanges.mk
CppunitTest_sc_scenariosobj.mk
CppunitTest_sc_screenshots.mk
CppunitTest_sc_shapeobj.mk
CppunitTest_sc_shapetest.mk
CppunitTest_sc_sheetlinkobj.mk
CppunitTest_sc_sheetlinksobj.mk
CppunitTest_sc_sortdescriptorbaseobj.mk
CppunitTest_sc_sparkline_test.mk
CppunitTest_sc_spreadsheet_functions_test.mk
CppunitTest_sc_spreadsheetsettings.mk
CppunitTest_sc_spreadsheetsettingsobj.mk
CppunitTest_sc_statistical_functions_test.mk
CppunitTest_sc_stylefamiliesobj.mk
CppunitTest_sc_stylefamilyobj.mk
CppunitTest_sc_styleobj.mk
CppunitTest_sc_subsequent_export_test.mk
CppunitTest_sc_subsequent_export_test2.mk
CppunitTest_sc_subsequent_filters_test.mk
CppunitTest_sc_subsequent_filters_test2.mk
CppunitTest_sc_subtotaldescriptorbase.mk
CppunitTest_sc_subtotalfieldobj.mk
CppunitTest_sc_tablecolumnobj.mk
CppunitTest_sc_tablecolumnsobj.mk
CppunitTest_sc_tableconditionalentryobj.mk
CppunitTest_sc_tableconditionalformat.mk
CppunitTest_sc_tablerowobj.mk
CppunitTest_sc_tablerowsobj.mk
CppunitTest_sc_tablesheetobj.mk
CppunitTest_sc_tablesheetsobj.mk
CppunitTest_sc_tablevalidationobj.mk
CppunitTest_sc_tabviewobj.mk
CppunitTest_sc_text_functions_test.mk
CppunitTest_sc_tiledrendering.mk Make LOKClipboard available to other modules 2023-02-06 17:02:54 +00:00
CppunitTest_sc_ucalc.mk
CppunitTest_sc_ucalc_condformat.mk
CppunitTest_sc_ucalc_copypaste.mk
CppunitTest_sc_ucalc_datatransformation.mk
CppunitTest_sc_ucalc_formula.mk
CppunitTest_sc_ucalc_parallelism.mk
CppunitTest_sc_ucalc_pivottable.mk
CppunitTest_sc_ucalc_range.mk
CppunitTest_sc_ucalc_rangelst.mk
CppunitTest_sc_ucalc_sharedformula.mk
CppunitTest_sc_ucalc_sort.mk
CppunitTest_sc_ucalc_sparkline.mk
CppunitTest_sc_uicalc.mk
CppunitTest_sc_uniquecellformatsenumeration.mk
CppunitTest_sc_uniquecellformatsobj.mk
CppunitTest_sc_vba_macro_test.mk
CppunitTest_sc_viewpaneobj.mk
functions_setup.mk
IwyuFilter_sc.yaml
JunitTest_sc_complex.mk
JunitTest_sc_unoapi_1.mk
JunitTest_sc_unoapi_2.mk
JunitTest_sc_unoapi_3.mk
JunitTest_sc_unoapi_4.mk
JunitTest_sc_unoapi_6.mk
JunitTest_sc_unoapi_7.mk
Library_sc.mk
Library_scd.mk
Library_scfilt.mk
Library_scqahelper.mk
Library_scui.mk
Library_vbaobj.mk
Makefile
Module_sc.mk Split long-running CppunitTest_sc_opencl_test in two 2023-01-27 14:28:34 +00:00
Package_opencl.mk
Package_res_xml.mk
PythonTest_sc_python.mk
README.md
subsequent_setup.mk
ucalc_setup.mk
UIConfig_scalc.mk
UITest_autofilter.mk
UITest_autofilter2.mk
UITest_calc_dialogs.mk
UITest_calc_tests.mk
UITest_calc_tests2.mk
UITest_calc_tests3.mk
UITest_calc_tests4.mk
UITest_calc_tests6.mk
UITest_calc_tests7.mk
UITest_calc_tests8.mk
UITest_calc_tests9.mk
UITest_chart.mk
UITest_chart2.mk
UITest_conditional_format.mk
UITest_csv_dialog.mk
UITest_external_links.mk
UITest_function_wizard.mk
UITest_goalSeek.mk
UITest_inputLine.mk
UITest_key_f4.mk
UITest_manual_tests.mk
UITest_pageFormat.mk
UITest_pasteSpecial.mk
UITest_protect.mk
UITest_range_name.mk
UITest_sc_options.mk
UITest_search_replace.mk
UITest_signatureLine.mk
UITest_solver.mk
UITest_sort.mk
UITest_statistics.mk
UITest_textCase.mk
UITest_textToColumns.mk
UITest_validity.mk

Spreadsheet Application Code

You can dump some information in a dbgutil build:

Shortcuts

CTRL+SHIFT+F12

Dumps the column width of the first 20 columns.

CTRL+SHIFT+F11

Dumps the graphic objects and their position and size in pixel.

CTRL+SHIFT+F6

Dumps the SfxItemSet representing the cell properties' of the current selection as a xml file. The file will be named dump.xml

The Cache Format

ScDocument::StoreTabToCache allows storing the content (not the formatting) of a table to a binary cache format.

The format is column orientated which allows quick serialization of the table.

  • Header:

    • Number of Columns: 64 bit unsigned integer
  • Column:

    • Column Index: 64 bit unsigned integer
    • Column Size: 64 bit unsigned integer
    • For each cell type block a new ColumnBlock
  • ColumnBlock:

    • Start Row: 64 bit unsigned integer
    • Block Size: 64 bit unsigned integer
    • Type: 8 bit unsigned integer
      • 0 : empty
      • 1 : numeric
        • for each cell: 64 bit IEEE 754 double precision value
      • 2 : string
        • for each cell: 32 bit signed string length followed by string length bytes of the string (UTF-8)
      • 3 : formula
        • for each cell: 32 bit signed string length followed by the formula in R1C1 notation as a string

Functions Supporting Wildcards or Regular Expressions

As this comes up every now and then, and rather should be documented in an extra list of the Help system, functions that support Wildcards or Regular Expressions and depend on the setting under Tools -> Options -> Calc -> Calculate are those that in ODF OpenFormula (ODFF) are defined to depend on the HOST-USE-REGULAR-EXPRESSIONS or HOST-USE-WILDCARDS properties, see https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html

  • Database Functions
    • DAVERAGE
    • DCOUNT
    • DCOUNTA
    • DGET
    • DMAX
    • DMIN
    • DPRODUCT
    • DSTDEV
    • DSTDEVP
    • DSUM
    • DVAR
    • DVARP
  • Information Functions
    • COUNTIF
    • COUNTIFS
  • Lookup Functions
    • HLOOKUP
    • LOOKUP
    • MATCH
    • VLOOKUP
  • Mathematical Functions
    • SUMIF
    • SUMIFS
  • Statistical Functions
    • AVERAGEIF
    • AVERAGEIFS
  • Text Functions
    • SEARCH