Bug 151979 - Crash when changing Text Grid type after I switch from Calc to Writer window
Summary: Crash when changing Text Grid type after I switch from Calc to Writer window
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.2.3 release
Hardware: All All
: medium normal
Assignee: Kevin Suo
URL:
Whiteboard: target:7.5.0 target:7.4.4
Keywords: haveBacktrace
Depends on:
Blocks: Text-Grid
  Show dependency treegraph
 
Reported: 2022-11-09 15:47 UTC by Kevin Suo
Modified: 2022-11-12 11:06 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
bt with debug symbols (6.61 KB, text/plain)
2022-11-09 17:35 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Suo 2022-11-09 15:47:12 UTC
Steps to Reproduce:
1. New Calc, New Writer. Arrange them side by side for easier operation.
2. In Writer, go to Format > Page Style > Text Grid.
3. Switch to Calc window, then switch to back to Writer window and try to click the 3rd grid type (i.e. Grid (lines and characters).

--> Crashes.

Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: b887d67ff9914100df787bd2036b22bf32456fab
CPU threads: 8; OS: Linux 6.0; UI render: default; VCL: gtk3
Locale: zh-CN (zh_CN.UTF-8); UI: en-US
Calc: threaded
Fedora 36

Also in latest 7.4 branch as of today.

bt:
(gdb) bt full
#0  0x00007fff2bb49194 in rtl::Reference<SvxRuler>::get() const () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/include/rtl/ref.hxx:208
#1  0x00007fff2bb48e3a in VclPtr<SvxRuler>::operator SvxRuler*() const () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/include/vcl/vclptr.hxx:182
#2  0x00007fff2bb48dae in SwView::GetHRuler() () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/inc/view.hxx:494
#3  0x00007fff2bb46bec in SwTextGridPage::PutGridItem(SfxItemSet&) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/ui/misc/pggrid.cxx:252
#4  0x00007fff2bb486bd in SwTextGridPage::GridModifyHdl() () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/ui/misc/pggrid.cxx:516
#5  0x00007fff2bb48180 in SwTextGridPage::TextSizeChangedHdl(weld::MetricSpinButton&) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/ui/misc/pggrid.cxx:456
#6  0x00007fff2bb484aa in SwTextGridPage::GridTypeHdl(weld::Toggleable&) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/ui/misc/pggrid.cxx:487
#7  0x00007fff2bb481af in SwTextGridPage::LinkStubGridTypeHdl(void*, weld::Toggleable&) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/ui/misc/pggrid.cxx:459
#8  0x00007fffd8e0950b in Link<weld::Toggleable&, void>::Call(weld::Toggleable&) const () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/include/tools/link.hxx:111
#9  0x00007fffd8dffaa5 in weld::Toggleable::signal_toggled() () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/include/vcl/weld.hxx:1505
#10 0x00007fffd8db24a2 in (anonymous namespace)::GtkInstanceCheckButton::signalToggled(void*, void*) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/vcl/unx/gtk3/gtkinst.cxx:12461

Probably because the https://opengrok.libreoffice.org/xref/core/sw/source/ui/misc/pggrid.cxx?r=384167ab#244
SwView * pView = ::GetActiveView()
points to the view in Calc instead of Writer thus the ruler does not exist?
Comment 1 jcsanz 2022-11-09 16:43:06 UTC
Confirmed

Also crashes if you choose the second grid type, i.e. Grid (lines only), but it does not crash if select the first option (No grid)

Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: bdb76c9ff1832041fa7a9bda30e8d4d7d937ff94
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded
Comment 2 Julien Nabet 2022-11-09 17:35:04 UTC
Created attachment 183502 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today, I could reproduce this with gtk + gen renderings, I attached bt with gen rendering.
Comment 3 Kevin Suo 2022-11-09 20:24:24 UTC
(In reply to Julien Nabet from comment #2)
So the SwView here is nullptr.

> but it does not crash if select the first option (No grid)
That's because if (aGridItem.GetGridType() == GRID_NONE) then the "get ruler" code will not be run.
Comment 4 Kevin Suo 2022-11-10 02:27:15 UTC
Proposed fix submitted as:
https://gerrit.libreoffice.org/c/core/+/142508
Comment 5 Commit Notification 2022-11-11 07:31:42 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9b80b2d6140d1aad240f10755105e49d678b98f1

tdf#151979: fix crash in Text Grid dialog when switching active view

It will be available in 7.5.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 6 Commit Notification 2022-11-12 11:06:07 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

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

tdf#151979: fix crash in Text Grid dialog when switching active view

It will be available in 7.4.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.