office-gobmx/svl
Noel Grandin bc0d05bdc0 try to fix crash in JunitTest_svx_unoapi
Seen by vmiklos locally, and by myself on jenkins. I cannot
reproduce this locally, so this is somewhat of a blind fix.

Program terminated with signal SIGSEGV, Segmentation fault.
$#0  0x00007f3e995c273a in sdr::properties::AttributeProperties::Notify (this=0x7f3e7000deb0, rBC=..., rHint=...)
    at /home/vmiklos/git/libreoffice/core/svx/source/sdr/properties/attributeproperties.cxx:464
464                                         pNewStSh = static_cast<SfxStyleSheet*>(rModel.GetStyleSheetPool()->Find(
[Current thread is 1 (Thread 0x7f3e6d2566c0 (LWP 18774))]
(gdb) bt
$#0  0x00007f3e995c273a in sdr::properties::AttributeProperties::Notify(SfxBroadcaster&, SfxHint const&) (this=0x7f3e7000deb0, rBC=..., rHint=...)
    at /home/vmiklos/git/libreoffice/core/svx/source/sdr/properties/attributeproperties.cxx:464
$#1  0x00007f3e995bd674 in sdr::properties::TextProperties::Notify(SfxBroadcaster&, SfxHint const&) (this=0x7f3e7000deb0, rBC=..., rHint=...)
    at /home/vmiklos/git/libreoffice/core/svx/source/sdr/properties/textproperties.cxx:549
$#2  0x00007f3e9b421176 in SfxBroadcaster::Broadcast(SfxHint const&) (this=0x7f3e683ce5f0, rHint=...) at /home/vmiklos/git/libreoffice/core/svl/source/notify/SfxBroadcaster.cxx:40
$#3  0x00007f3e9b35fdad in (anonymous namespace)::StyleSheetDisposerFunctor::Dispose(rtl::Reference<SfxStyleSheetBase>) (this=0x7f3e6d2532a0, styleSheet=rtl::Reference to 0x7f3e6830c260)
    at /home/vmiklos/git/libreoffice/core/svl/source/items/style.cxx:762
$#4  0x00007f3e9b31b2bd in svl::IndexedStyleSheets::Clear(svl::StyleSheetDisposer&) (this=0x7f3e685ebd50, disposer=...)
    at /home/vmiklos/git/libreoffice/core/svl/source/items/IndexedStyleSheets.cxx:187
$#5  0x00007f3e9b35fe8d in SfxStyleSheetBasePool::Clear() (this=0x7f3e683ce5f0) at /home/vmiklos/git/libreoffice/core/svl/source/items/style.cxx:773
$#6  0x00007f3e9b35f0d7 in SfxStyleSheetBasePool::~SfxStyleSheetBasePool() (this=0x7f3e683ce5f0, __in_chrg=<optimized out>)
    at /home/vmiklos/git/libreoffice/core/svl/source/items/style.cxx:580
$#7  0x00007f3e4c4d217e in __static_initialization_and_destruction_0(int, int) (__initialize_p=32574, __priority=1748821488) at /usr/include/c++/12/iostream:74
$#8  0x00007f3e4c4cedba in std::construct_at<ScSortKeyState, ScSortKeyState>(ScSortKeyState*, ScSortKeyState&&) (__location=0x7f3e683ce5f0) at /usr/include/c++/12/bits/stl_construct.h:94
$#9  0x00007f3e683ce5f0 in  ()
$#10 0x00007f3e6d253380 in  ()
$#11 0x00007f3e4c4ceddc in std::construct_at<ScSortKeyState, ScSortKeyState>(ScSortKeyState*, ScSortKeyState&&)
    (__location=0x7f3e4c4ceddc <std::construct_at<ScSortKeyState, ScSortKeyState>(ScSortKeyState*, ScSortKeyState&&)+36>) at /usr/include/c++/12/bits/stl_construct.h:97
$#12 0x00007f3e9e756ce4 in cppu::OWeakObject::release() (this=0x7f3e683ce668) at /home/vmiklos/git/libreoffice/core/cppuhelper/source/weak.cxx:229
$#13 0x00007f3e4c460e26 in std::__uniq_ptr_impl<SvNumberFormatter, std::default_delete<SvNumberFormatter> >::operator=(std::__uniq_ptr_impl<SvNumberFormatter, std::default_delete<SvNumberFormatter> >&&) (this=0x7f3e683ce668, __u=...) at /usr/include/c++/12/bits/unique_ptr.h:184
$#14 0x00007f3e4c460c30 in rtl::Reference<ScStyleSheetPool>::~Reference() (this=0x7f3e683ce5f0, __in_chrg=<optimized out>) at /home/vmiklos/git/libreoffice/core/include/rtl/ref.hxx:126
$#15 0x00007f3e4c460175 in ScPoolHelper::ScPoolHelper(ScDocument&) (this=0x7f3e683ce5f0, rSourceDoc=...) at /home/vmiklos/git/libreoffice/core/sc/source/core/data/poolhelp.cxx:33
$#16 0x00007f3e4c4601fc in ScPoolHelper::ScPoolHelper(ScDocument&) (this=0x7f3e682a3370, rSourceDoc=...) at /home/vmiklos/git/libreoffice/core/sc/source/core/data/poolhelp.cxx:34
$#17 0x00007f3e4bddcf52 in cppu::OWeakObject::operator delete(void*) (pMem=0x7f3e4bddcf52 <cppu::OWeakObject::operator delete(void*)+3>)
    at /home/vmiklos/git/libreoffice/core/include/cppuhelper/weak.hxx:90
$#18 0x00007f3e682a3370 in  ()
$#19 0x00007f3e6d253480 in  ()
$#20 0x00007f3e4c0bda00 in VclPtr<VirtualDevice>::disposeAndClear() (this=Python Exception <class 'gdb.MemoryError'>: Cannot access memory at address 0xffffffffffffffd8

Change-Id: I936b5042a368b08a20ea9f545892ef8a6625f5fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171235
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-07-30 21:06:57 +02:00
..
inc/pch
qa
source try to fix crash in JunitTest_svx_unoapi 2024-07-30 21:06:57 +02:00
unx/source/svdde
util
AllLangMoTarget_svl.mk
CppunitTest_svl_adrparse.mk
CppunitTest_svl_inetcontenttype.mk
CppunitTest_svl_items.mk
CppunitTest_svl_lngmisc.mk
CppunitTest_svl_lockfiles.mk
CppunitTest_svl_notify.mk
CppunitTest_svl_qa_cppunit.mk
CppunitTest_svl_urihelper.mk
IwyuFilter_svl.yaml
JunitTest_svl_complex.mk
Library_fsstorage.mk
Library_passwordcontainer.mk
Library_svl.mk
Makefile
Module_svl.mk
README.md

Non-Graphical Helper Code (svtools light)

Contains non-graphical helper code for office applications.

Specifically this module does not depend on or use includes from module vcl. Originally all code in svtools that did not depend on vcl was split off into this svl ("svtools light") module.

In particular the SfxItemSet is a property-bag like container that stores arbitrary sets of properties for everything from text run formats, to Chart regression line properties.

There are lots of other useful helpers in here for various office tasks; much of this code was originally moved from svx/sfx2.

Items, Pools and Sets

SfxPoolItem

A small reference counted piece of data. Many subclasses, each with a unique integer to identify its type (WhichId). Can be compared for equality (operator==), Clone()d, and converted to/from uno::Any (QueryValue/PutValue).

A pool item may have value semantics ("poolable"), meaning that there will generally be only one instance that compares equal per item pool, or not, in which case the item will be Clone()d quite a bit.

SfxItemPool

Usually there is one item pool per document, with a range of valid WhichIds that is specific to the type of document.

The item pool owns all instances of SfxPoolItem or its subclasses that have ever been added to an item set. It also contains a default item for every WhichId, which will be (depending on parameters) returned from item sets if the set does not contain an item at this WhichId.

SfxItemSet

The item set can be created with a user-supplied range of WhichIds; it will accept SfxPoolItems with matching WhichIds and ignore attempts to insert items with non-matching WhichIds.

Items that are successfully inserted into the set will be stored in the set's SfxItemPool, and for poolable items only a single instance that compares equal under the predicate operator== will be stored in the pool, regardless of how many sets contain it, thus conserving memory.

There are members m_pWhichRanges for the valid ranges (as pairs of WhichIds), m_nCount for the number of items contained, and m_pItems for the pointers to the actual items.