Bug 112658 - TextEngine::SetAttrib(TextAttrib const&, unsigned int, int, int, bool) leaks memory with multiple invocations
Summary: TextEngine::SetAttrib(TextAttrib const&, unsigned int, int, int, bool) leaks ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.0.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:6.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-26 11:00 UTC by Telesto
Modified: 2017-09-28 11:57 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
BT & Few screenshots (2.03 MB, application/x-zip-compressed)
2017-09-26 11:01 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 11:00:35 UTC
Description:
TextEngine::SetAttrib(TextAttrib const&, unsigned int, int, int, bool) 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. Type some wrongly spelled text 
8. Open the spelling dialog Tools -> Spelling
9. Correct or ignore suggestions
10. Close the spelling dialog
11. Stop recording (after the closing is fully processed) 
12. Analyse the profile trace.

Actual Results:  
TextEngine::SetAttrib(TextAttrib const&, unsigned int, int, int, bool) leaks memory with multiple invocations

Expected Results:
Shouldn't leak


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Telesto 2017-09-26 11:01:05 UTC
Created attachment 136542 [details]
BT & Few screenshots
Comment 2 Julien Nabet 2017-09-26 14:34:28 UTC
I'll give it a try.
Comment 3 Telesto 2017-09-26 15:14:06 UTC
(In reply to Julien Nabet from comment #2)
> I'll give it a try.
Is this one related: https://gerrit.libreoffice.org/#/c/42787/ ?
Comment 4 Julien Nabet 2017-09-26 21:14:02 UTC
I confirm the leak but not so easy to tackle :-(
Comment 5 Julien Nabet 2017-09-27 08:30:57 UTC
(In reply to Telesto from comment #3)
> (In reply to Julien Nabet from comment #2)
> > I'll give it a try.
> Is this one related: https://gerrit.libreoffice.org/#/c/42787/ ?

It may help but don't think so.

I think we should even change:
void SentenceEditWindow_Impl::SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd )
to void SentenceEditWindow_Impl::SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_Int32 nStart, sal_Int32 nEnd )

to match with:
void TextEngine::SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_Int32 nStart, sal_Int32 nEnd, bool bIdleFormatAndUpdate )

It supposes to change m_nErrorStart and m_nErrorEnd
Comment 6 Julien Nabet 2017-09-27 22:23:19 UTC
Let's give a try by submitting to review this patch:
https://gerrit.libreoffice.org/#/c/42881/
Comment 7 Commit Notification 2017-09-28 11:11:21 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=19910c461230f70bb9e98ad44db3525f0d755724

tdf#112658: fix leak when calling TextEngine::SetAttrib

It will be available in 6.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Julien Nabet 2017-09-28 11:57:28 UTC
It seems it's not a big leak according to the comments here:
https://gerrit.libreoffice.org/#/c/42881/4
So let's put this one to FIXED.