Index ¦ Archives ¦ RSS

8884 VirtualDevices

Estimated read time: 2 minutes

(via teq)

If you are into C++ programming, you probably know that smart pointers are not just literally strange things like the above ones. ;-) LibreOffice 5.0 got VclPtr, which is smart pointer specialized to VCL’s needs.

Such refactorings are good things, except that there is no huge rework without regressions. In this case the WMF filter had 3 places where we were leaking VirtualDevices due to a misconversion to the new VclPtr API. The problem was that the document had 135 images, WMF files to be exact. Now given that the leaks were during parsing of WMF records (a WMF file consists of multiple WMF records), at the end we leaked 8884 VirtualDevices. At first the problem was seen as Windows-specific, as at least X on Linux has no problem with creating that many VirtualDevices, but Windows' default resource limits are hit in this case.

A note about testing this bugfix effectively, so it never happens again. The problem was that I wanted to create a minimal reproducer, but I also needed a document with lots of WMF images, each complex enough to trigger the resource limit. At the end I manually created a DOCX file that had the same image copy&pasted multiple times: that way we really imported them multiple times (normally we notice that they’re the same, and only save the image to the file once, and put multiple references to it), and because DOCX is also a ZIP container, the test file can be still only 99KB instead of the original 17MB RTF.

Thanks to the 4.4 → 5.0 Windows bibisect repo, it was immediately obvious that this is a VclPtr problem, and then it was possible to identify the root cause, and finally see that the bug title mentioning RTF was just container of the WMF images in this case, the problem had nothing to with with RTF and the leak wasn’t Windows-specific, either.

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.