On 5/25/19 9:44 AM, Kornel Benko wrote:
> 1.) Open lib/doc/Customization.lyx
> 2.) Save as CustomizationMin.lyx in different directory --> crash
> The file CustomizationMin.lyx looks OK though.
>
> Backtrace:
> Thread 1 "lyx2.4" received signal SIGSEGV, Segmentation fault.
> 0x0000000000d9c4b8 in lyx::CursorSlice::text() const (this=0x2c44160)
>     at /usr2/src/lyx/lyx-git/src/CursorSlice.h:119
> 119           Text * text() const { return inset_->getText(idx_); }
> (gdb) p inset_
> No symbol "inset_" in current context.
> (gdb) bt
> #0  0x0000000000d9c4b8 in lyx::CursorSlice::text() const (this=0x2c44160) at 
> /usr2/src/lyx/lyx-git/src/CursorSlice.h:119
> #1  0x0000000000cf8050 in lyx::DocIterator::innerTextSlice() const 
> (this=0x2f57400)
>     at /usr2/src/lyx/lyx-git/src/DocIterator.cpp:233

Like others, I can confirm. Bisect points at

commit 91a5263d681c60544501bd402b8c5c215ea071bd (HEAD, refs/bisect/bad)
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Wed Aug 8 15:05:58 2018 +0200

    Extend list of accessible menu info
   
    When searching for and item in the menu, also try to consider those that
    require a BufferView (such as View/Update formats).
   
    Also, be explicit for the default format in order to find it.
   
    Fixes: #9851

You get the same crash if you modify (a copy of) Customization.lyx and
then Revert to Saved.

The problem is a stale TOC from before we reloaded the Buffer: When we
get to

            submenu.expandTocSubmenu(toc.first, *toc.second);

in Menus::expandToc, toc.first is "branch" (because that is a type of
TOC we had before) but toc.second is an empty vector, and eventually we
crash.

The attached fixes it for me, but I'm not sure it's correct.

Riki


diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 6665a731e1..008750a9bf 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5430,6 +5430,7 @@ Buffer::ReadStatus Buffer::reload()
        d->setParent(0);
        ReadStatus const status = loadLyXFile();
        if (status == ReadSuccess) {
+               tocBackend() = TocBackend(this);
                updateBuffer();
                changed(true);
                updateTitles();

Reply via email to