Bug 112657 - SfxUndoManager_Data::SfxUndoManager_Data leaks memory with multiple invocations
Summary: SfxUndoManager_Data::SfxUndoManager_Data leaks memory with multiple invocations
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.0.0.0.alpha0+
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Memory
  Show dependency treegraph
 
Reported: 2017-09-26 10:16 UTC by Telesto
Modified: 2023-01-12 03:20 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
BT & Few screenshots (2.43 MB, application/x-zip-compressed)
2017-09-26 10:16 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2017-09-26 10:16:18 UTC
Description:
SfxUndoManager_Data::SfxUndoManager_Data leaks memory with multiple invocations 

Steps to Reproduce:
1. Start the Instruments.app
2. Choose Memory Leak profile tool
3. Select LibreOffice.app in instdir as target process
4. Click on the record button, LODev is started by the profiling tool
5. Wait for the StartCenter to load.
6. Click on the new Writer document icon to open a blank Writer document.
7. Insert a chart with the toolbar icon
8. Select the chart and delete (backspace)
9. Stop recording (after the closing is fully processed) 
10. Analyse the profile trace.

Actual Results:  
SfxUndoManager_Data::SfxUndoManager_Data leaks memory
SfxUndoActions::SfxUndoActions() leaks memory
osl::Mutex::Mutex()leaks memory


Expected Results:
No leaks


Reproducible: Always

User Profile Reset: No

Additional Info:
Recent MacOS build


User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Telesto 2017-09-26 10:16:52 UTC
Created attachment 136540 [details]
BT & Few screenshots
Comment 2 Alex Thurgood 2017-09-26 15:18:19 UTC
Confirming, and allegedly leaking here :

struct SfxUndoActions::Impl
{
    std::vector<MarkedUndoAction> maActions;
};

SfxUndoActions::SfxUndoActions() : mpImpl(new Impl) {}

SfxUndoActions::SfxUndoActions( const SfxUndoActions& r ) :
    mpImpl(new Impl)
{
    mpImpl->maActions = r.mpImpl->maActions;
}

SfxUndoActions::~SfxUndoActions()
{
}


in undo.cxx, lines 152-167
Comment 3 Alex Thurgood 2017-09-26 15:22:32 UTC
(In reply to Alex Thurgood from comment #2)
> Confirming, and allegedly leaking here :
> 

Ignore the previous code pointer, I was looking at the wrong part, it seems, but the UndoManager code here might be more promising:

    explicit SfxUndoManager_Data( size_t i_nMaxUndoActionCount )
        :pUndoArray( new SfxUndoArray( i_nMaxUndoActionCount ) )
        ,pActUndoArray( nullptr )
        ,mnMarks( 0 )
        ,mnEmptyMark(MARK_INVALID)
        ,mbUndoEnabled( true )
        ,mbDoing( false )
        ,mbClearUntilTopLevel( false )
    {
        pActUndoArray = pUndoArray.get();
    }


lines 233-243 of undo.cxx
Comment 4 Alex Thurgood 2017-09-26 15:25:34 UTC
Line 691 of ChartModel.cxx also gets pointed to by the Apple Instruments tool:

        m_pUndoManager.set( new UndoManager( *this, m_aModelMutex ) );
Comment 5 Alex Thurgood 2017-09-26 15:26:50 UTC
Along with line 835 of undomanagerhelper.cxx :

        :m_xImpl( new UndoManagerHelper_Impl( i_undoManagerImpl ) )
Comment 6 Julien Nabet 2017-09-28 19:57:59 UTC
I traced the number of calls to constructor and destructor.
For ChartModel, it's ok, same number
It's wrong for UndoManager, I only see calls to its constructor, none for destructor.
The use of UndoManager in ChartModel is:
::rtl::Reference< UndoManager > m_pUndoManager;
(see https://opengrok.libreoffice.org/xref/core/chart2/inc/ChartModel.hxx#133)

I noticed destructor of ChartModel is:
196  ChartModel::~ChartModel()
197  {
198      if( m_xOldModelAgg.is())
199          m_xOldModelAgg->setDelegator( nullptr );
200  }

But then I'm completely lost since I don't know enough about rtl::reference, weak ref, acquire/release, dispose/disposing to help here.
Comment 7 QA Administrators 2018-09-29 02:42:17 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2021-01-11 03:55:05 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2023-01-12 03:20:41 UTC
Dear Telesto,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug