Bug 158323 - CRASH when switch back from HTML View to Normal View after edit in HTML source code
Summary: CRASH when switch back from HTML View to Normal View after edit in HTML sourc...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer Web (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium critical
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, haveBacktrace, regression
Depends on:
Blocks: Crash
  Show dependency treegraph
 
Reported: 2023-11-22 16:12 UTC by Rainer Bielefeld Retired
Modified: 2023-11-23 12:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample Document (586 bytes, text/html)
2023-11-22 16:12 UTC, Rainer Bielefeld Retired
Details
gdb bt (21.67 KB, text/plain)
2023-11-23 12:21 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Bielefeld Retired 2023-11-22 16:12:26 UTC
Created attachment 190974 [details]
Sample Document

Steps how to reproduce with Server Installation of Version: 24.2.0.0.alpha0+ (X86_64)
Build ID: 7fff4e2ca6739928f72e5f0d2eb5820823916769
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; 
Locale: Locale: de-DE (de_DE); UI: de-DE; Theme: Colibre
Calc: CL threaded – normal Test Profile created from 7.6
1. Open sample document "own.HTML"
2. HTM Source View
3. Delete word "mein" in first line of body
5. Menu ˋView → Uncheck 'HTML Source'ˊ
   » Expected: WISIWYG
    Actual: CRASH

Additional info:
a) was still ok with
   Version: 7.6.1.1 (X86_64) / LibreOffice Community
   Build ID: c7cda394c5de06de37d8109c310df89a4d4c3a98
   CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: 
      win
   Locale: de-DE (de_DE); UI: de-DE
   Calc: threaded
a1) and all other versions before 24.2 I tested until back to OOo 3.2.0
b) any edit I tried (delete, add, modify) caused the crash
c) Crash Dump IDs (for example):
   6e1eb488-df8e-42ce-aa8f-a2157f86d548
   8cb977a8-174d-44c0-af92-f81911481eb3
   c9c02c5d-f9ef-42a2-8149-656f14d70581
Comment 1 Stéphane Guillou (stragu) 2023-11-22 20:24:19 UTC
Thank you for the report!

(In reply to Rainer Bielefeld Retired from comment #0)
> 1. Open sample document "own.HTML"
> 2. HTM Source View
I had to use the command "create HTML document" (.uno:NewHtmlDoc) before being able to use that source view (.uno:SourceView).

Reproduced the crash:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 7d357628d6e8ce3f9e3c3a567ada21f02bce8d42
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Without sample doc:
1. Open Writer
2. File > New > HTML document
3. Write "Test"
4. Switch to Source View, save document as prompted
5. Remove "Test" from the source
6. Turn Source View off

No repro in:

Version: 7.6.3.1 (X86_64) / LibreOffice Community
Build ID: c4af5b1259bceea6e979e6fe2435dbee7a5a87c2
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 2 Stéphane Guillou (stragu) 2023-11-23 09:28:27 UTC
Bibisected with linux-64-24.2 repo to first bad build commit [867559232d567aefa2ba108a880f93431008ef2a] which points to:

commit d934aeace6e7049db3959421538ae382cb97b1d1
author	Maxim Monastirsky 	Thu Jun 15 11:16:18 2023 +0300
committer	Maxim Monastirsky 	Fri Jun 16 00:48:44 2023 +0200
tdf#103064 sw,editeng: make para styles work inside comments
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153156

Maxim, can you please have a look?
Comment 3 Julien Nabet 2023-11-23 12:21:12 UTC
Created attachment 190990 [details]
gdb bt

On pc Debian x86-64 with master sources updated today, I could reproduce this.

I attached bt with gdb console logs if it can help.
Comment 4 Julien Nabet 2023-11-23 12:32:07 UTC
I don't know if it's expected that GetStyleSheetPool may return null.
If it is, this patch can fix this:
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 12c5e4f52d11..c69402c8583e 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -225,7 +225,9 @@ SwPostItMgr::SwPostItMgr(SwView* pView)
     StartListening(*mpView->GetDocShell());
     // listen to stylesheet pool to update on stylesheet rename,
     // as EditTextObject references styles by name.
-    StartListening(*static_cast<SwDocStyleSheetPool*>(mpView->GetDocShell()->GetStyleSheetPool())->GetEEStyleSheetPool());
+    SfxStyleSheetBasePool* pPool = mpView->GetDocShell()->GetStyleSheetPool();
+    if  (pPool)
+        StartListening(*static_cast<SwDocStyleSheetPool*>(pPool)->GetEEStyleSheetPool());
     if (!mvPostItFields.empty())
     {
         mbWaitingForCalcRects = true;