On 2/23/20 4:11 PM, Scott Kostyshak wrote:
> On Sun, Feb 23, 2020 at 03:54:06PM -0500, Richard Kimberly Heck wrote:
>> On 2/23/20 2:31 PM, Scott Kostyshak wrote:
>>> On Sun, Feb 23, 2020 at 12:50:42PM -0500, Richard Kimberly Heck wrote:
>>>> On 2/23/20 8:23 AM, Scott Kostyshak wrote:
>>>>> On Tue, Feb 18, 2020 at 08:28:33PM -0500, Scott Kostyshak wrote:
>>>>>> On Tue, Feb 18, 2020 at 07:33:39PM -0500, Richard Kimberly Heck wrote:
>>>>>>> On 2/18/20 6:07 PM, Scott Kostyshak wrote:
>>>>>>>> Valgrind gave me the following error:
>>>>>>>>
>>>>>>>>   ==732== 112 (72 direct, 40 indirect) bytes in 1 blocks are 
>>>>>>>> definitely lost in loss record 5,165 of 5,862
>>>>>>>>   ==732==    at 0x483AE63: operator new(unsigned long) (in 
>>>>>>>> /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
>>>>>>>>   ==732==    by 0x103A62D: lyx::Buffer::cloneBufferOnly() const 
>>>>>>>> (Buffer.cpp:661)
>>>>>>>>   ==732==    by 0x11E583C: lyx::(anonymous 
>>>>>>>> namespace)::copyToTempBuffer(lyx::ParagraphList const&, 
>>>>>>>> std::shared_ptr<lyx::DocumentClass const>) (CutAndPaste.cpp:582)
>>>>>>>>   ==732==    by 0x11E5C6A: lyx::(anonymous 
>>>>>>>> namespace)::putClipboard(lyx::ParagraphList const&, 
>>>>>>>> std::shared_ptr<lyx::DocumentClass const>, 
>>>>>>>> std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, 
>>>>>>>> std::allocator<wchar_t> > const&, lyx::BufferParams) 
>>>>>>>> (CutAndPaste.cpp:613)
>>>>>>>>   ==732==    by 0x11E910B: lyx::cap::copySelection(lyx::Cursor const&, 
>>>>>>>> std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, 
>>>>>>>> std::allocator<wchar_t> > const&) (CutAndPaste.cpp:1123)
>>>>>>>>   ==732==    by 0x11E84F8: lyx::cap::copySelection(lyx::Cursor const&) 
>>>>>>>> (CutAndPaste.cpp:1024)
>>>>>>>>   ==732==    by 0x13ECDAB: lyx::Text::dispatch(lyx::Cursor&, 
>>>>>>>> lyx::FuncRequest&) (Text3.cpp:1593)
>>>>>>>>   ==732==    by 0x1767E04: lyx::InsetText::doDispatch(lyx::Cursor&, 
>>>>>>>> lyx::FuncRequest&) (InsetText.cpp:339)
>>>>>>>>   ==732==    by 0x15FFC39: lyx::Inset::dispatch(lyx::Cursor&, 
>>>>>>>> lyx::FuncRequest&) (Inset.cpp:325)
>>>>>>>>   ==732==    by 0x11D1B13: lyx::Cursor::dispatch(lyx::FuncRequest 
>>>>>>>> const&) (Cursor.cpp:825)
>>>>>>>>   ==732==    by 0x1816F4F: 
>>>>>>>> lyx::frontend::GuiView::dispatchToBufferView(lyx::FuncRequest const&, 
>>>>>>>> lyx::DispatchResult&) (GuiView.cpp:3878)
>>>>>>>>   ==732==    by 0x181B959: 
>>>>>>>> lyx::frontend::GuiView::dispatch(lyx::FuncRequest const&, 
>>>>>>>> lyx::DispatchResult&) (GuiView.cpp:4569)
>>>>>>>>
>>>>>>>> It comes from the following line (Buffer.cpp:661):
>>>>>>>>
>>>>>>>>   cloned_buffers.push_back(new CloneList);
>>>>>>>>
>>>>>>>> Currently cloned_buffers is a list<CloneList *>. Would it make sense 
>>>>>>>> to make it a list of *smart* pointers instead? Alternatively we could 
>>>>>>>> make a class and then make a custom destructor that would free the 
>>>>>>>> CloneLists that the list elements point to?
>>>>>>> This is some kind of thinko, probably on my part. The code at line 549
>>>>>>> was supposed to be cleaning this up, but it actually only removes the
>>>>>>> entry from the list.
>>>>>>>
>>>>>>> If it works to make it a smart pointer of some kind, then that would be
>>>>>>> simplest. But I think we could just do something like:
>>>>>>>
>>>>>>> else {
>>>>>>>     delete(*it);
>>>>>>>     cloned_buffers.erase(it);
>>>>>>> }
>>>>>> Ah that makes sense.
>>>>> Riki, I propose that you commit. Thanks for the fix.
>>>> Just to check: You've verified this fixes the problem?
>>> I just tried to reproduce the original error (without the fix) and could
>>> not. I originally got the message from copying something and compiling.
>>> I just tried doing that with the Customization and Embedded Objects
>>> manuals, but I could not trigger the error.
>> Committed, then.
> Thanks for the fix. I'll continue testing LyX with Valgrind at some
> point in the future. Right now I'm tired of the waiting. I might look
> into the suggestions that Neven gave.

Actually, that is all wrong, and now I'm very confused. The patch causes
a double delete exception here, so I have reverted it. The line

    delete d->clone_list_;

already does this deletion, since *it just is d->clone_list_.

I've committed another patch with a shared_ptr. That has at least to help.

Riki


-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to