LyX 2.4 -- memory full when trying to copy a math block having boxed expression with 4 levels of nested deep subscript

Richard Kimberly Heck rikiheck at gmail.com
Sat May 18 16:35:25 UTC 2024


On 5/18/24 10:15, Alexander Dunlap wrote:
> On Sat, May 18, 2024, at 9:52 AM, Alexander Dunlap wrote:
>> On Sat, May 18, 2024, at 2:30 AM, Niranjana K M wrote:
>>> Dear LyX developers,
>>> Thank you and congratulations for heading towards much awaited LyX-2.4.
>>> I have been using LyX-2.4-RC1 from last 6 months and yesterday 
>>> accidentally i caught this strange behavior. And I even installed 
>>> recently released LyX-2.4 and the behavior persisted in this version 
>>> also. But i am not facing this problem in LyX-2.3.7.
>>> The problem is, when I try to copy, by selecting and pressing Ctrl+C 
>>> (or Copy from edit menu), a math block which is boxed and also 
>>> having deep nested subscripts to at least 4 levels then my computer 
>>> memory rapidly got consumed to the full (starting from 1GB to ~10GB) 
>>> and in the end LyX closed with following message.
>>>
>>> $ /usr/local/bin/lyx
>>> Error: Software exception Detected
>>> ----------------------------------------
>>> LyX has caught an exception, it will now attempt to save all unsaved 
>>> documents and exit.
>>> Exception: std::bad_alloc
>>> Aborted
>>>
>>> Following is the math block which caused it, (LyX code)
>>> \begin_inset Formula
>>> \[
>>> \boxed{v=\left[v_{p}\right]_{a_{0}}}
>>> \]
>>> \end_inset
>>>
>>> The file is also attached in the end and here is the screenshot of 
>>> the math block.
>>> Screenshot from 2024-05-18 11-43-00.png
>>>
>>> It is a legitimate construction and it gives no problem in LyX-2.3.7 
>>> (confirmed).
>>> If either the box is removed or the subscript 0 is removed from /a/, 
>>> then it has no issues in copying.
>>>
>>> All these versions I mentioned were compiled from source on Gentoo 
>>> Linux. This LyX-2.4 was compiled with the following configuration,
>>> $ ./configure --without-included-boost
>>> Configuration
>>>   Host type:               x86_64-pc-linux-gnu
>>>   Special build flags:      build=release callback-printing 
>>> use-hunspell use-aspell use-enchant
>>>   Bundled libraries:        nod
>>>   C++ Compiler:            g++ (13.2.1)
>>>   C++ Compiler flags:       -fPIC -O2 -std=c++17
>>>   C++ Compiler user flags:   -std=c++17  -march=native -O2 -pipe
>>>   Linker flags:             -rdynamic
>>>   Linker user flags:
>>>   Qt Frontend:
>>>       Qt version:   5.15.11
>>>   Packaging:               posix
>>>   LyX binary dir:          /usr/local/bin
>>>   LyX files dir:           /usr/local/share/lyx
>>>
>>> I loved the new features in LyX-2.4 and don't want to go back to 
>>> LyX-2.3.7 due to this issue. Please help in this regard.
>>
>> I can reproduce this. I investigated a little and it seems that the 
>> problem is that the "while (true)" loop in the splitAndWrapInMText 
>> function in InsetMathBox.cpp is never terminating. I believe that the 
>> reason for this is that the logic in this function is not correctly 
>> identifying the matching XHTML end tag for a given start tag, since 
>> it doesn't take into account nested tags properly.
>
> Here is a patch that fixes the problem for me. It needs extensive 
> checking/testing though because I do not know too much about XHTML or 
> what all sorts of input might be seen in this function.

Thanks! This looks good to me, but Thibaut should also have a look.

I have to rebuild 2.4.0 anyway, due to some build issues on Windows, so 
this could be included.

Riki

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20240518/cb19f161/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2024-05-18 11-43-00.png
Type: image/png
Size: 2400 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20240518/cb19f161/attachment.png>


More information about the lyx-devel mailing list