Bug 148949 - Libreoffice crash when trying to delete the "Standard" character style using API.
Summary: Libreoffice crash when trying to delete the "Standard" character style using ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: haveBacktrace
: 148950 (view as bug list)
Depends on:
Blocks: Crash
  Show dependency treegraph
 
Reported: 2022-05-05 10:14 UTC by vatairethibault
Modified: 2022-06-13 13:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
bt with debug symbols (14.25 KB, text/plain)
2022-05-05 11:46 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vatairethibault 2022-05-05 10:14:08 UTC
Description:
Libreoffice crash when trying to delete the "Standard" characters style using API.


Steps to Reproduce:
1. Open a Writer document
2. Open Tools > Macros > Organize Macros > Basic...
3. Edit a module and paste following content : 

Sub Writer
	thisComponent.StyleFamilies.getByName("CharacterStyles").removeByName("Standard")
End Sub

4. run the Writer function.


Actual Results:
LibreOffice crash immediately and the report dialog is displayed.

Crash report : https://crashreport.libreoffice.org/stats/crash_details/c04c4ad2-ceab-4e7e-918b-e3a0871d295a

Expected Results:
Libreoffice should not crash.


Reproducible: Always


User Profile Reset: Yes


Version: 7.1.4.2 / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 16; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded
Comment 1 Xisco Faulí 2022-05-05 11:16:14 UTC
*** Bug 148950 has been marked as a duplicate of this bug. ***
Comment 2 Xisco Faulí 2022-05-05 11:17:38 UTC
Reproduced in

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: fd7e3c0b5983b73d9a433678fa85950c219ea4a6
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded
Comment 3 Xisco Faulí 2022-05-05 11:24:45 UTC
@Julien, @Mike, I thought you might be interested in this issue
Comment 4 Xisco Faulí 2022-05-05 11:26:45 UTC
Also reproduced in

Version: 6.3.0.0.alpha1+
Build ID: c98b1f1cd43b3e109bcaf6324ef2d1f449b34099
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3; 
Locale: es-ES (es_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 5 Julien Nabet 2022-05-05 11:46:19 UTC
Created attachment 179944 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 6 Julien Nabet 2022-05-05 11:50:31 UTC
I tried this naive patch:
diff --git a/sw/source/core/undo/SwUndoFmt.cxx b/sw/source/core/undo/SwUndoFmt.cxx
index 110f138f5f3b..6f7855518271 100644
--- a/sw/source/core/undo/SwUndoFmt.cxx
+++ b/sw/source/core/undo/SwUndoFmt.cxx
@@ -99,7 +99,8 @@ SwUndoFormatDelete::SwUndoFormatDelete
       m_rDoc(rDoc), m_sOldName(_pOld->GetName()),
       m_aOldSet(_pOld->GetAttrSet())
 {
-    m_sDerivedFrom = _pOld->DerivedFrom()->GetName();
+    if (_pOld->DerivedFrom())
+        m_sDerivedFrom = _pOld->DerivedFrom()->GetName();
     m_nId = _pOld->GetPoolFormatId() & COLL_GET_RANGE_BITS;
     m_bAuto = _pOld->IsAuto();
 }

it won't crash the first time I run the macro but it crashes on a second time with this bt:
#0  SwClient::GetRegisteredIn() const (this=0x6666666600000001) at sw/inc/calbck.hxx:164
#1  0x00007f58c79db525 in SwFormat::DerivedFrom() const (this=0x6666666600000001) at sw/inc/format.hxx:128
#2  0x00007f58c79e9ad5 in SwFormat::IsDefault() const (this=0x6666666600000001) at sw/inc/format.hxx:129
#3  0x00007f58c8df50ab in lcl_FindCharFormat(SwDoc&, rtl::OUString const&, SwDocStyleSheet*, bool) (rDoc=..., rName="No Character Style", pStyle=0x58a2f30, bCreate=false)
    at sw/source/uibase/app/docstyle.cxx:146
#4  0x00007f58c8df2c03 in SwDocStyleSheet::FillStyleSheet(SwDocStyleSheet::FillStyleType, std::optional<SfxItemSet>*) (this=0x58a2f30, eFType=SwDocStyleSheet::FillOnlyName, o_ppFlatSet=0x0)
    at sw/source/uibase/app/docstyle.cxx:1878
#5  0x00007f58c8dfe859 in SwDocStyleSheetPool::Find(rtl::OUString const&, SfxStyleFamily, SfxStyleSearchBits) (this=0x58a3b10, rName="No Character Style", eFam=SfxStyleFamily::Char, n=SfxStyleSearchBits::All)
    at sw/source/uibase/app/docstyle.cxx:2603
#6  0x00007f58c8a26629 in sw::(anonymous namespace)::XStyleFamily::removeByName(rtl::OUString const&) (this=0x62c3cb0, rName="Standard") at sw/source/core/unocore/unostyle.cxx:1063

There must something really wrong but I don't know what.