Re: SIGSEGV on current master when saving with cursor in subscript
Le 16/04/2024 à 18:44, Jürgen Spitzmüller a écrit : Am Dienstag, dem 16.04.2024 um 12:08 +0200 schrieb Jean-Marc Lasgouttes: I propose the following patch. Can you check that it works? Works for me with both testcases. Thanks for testing, it is now in master. Riki, I think it is worth backporting. Where can I put it? It is triggered by the biginset branch, but it has merit of its own IMO. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
On Tue, Apr 16, 2024 at 06:44:25PM GMT, Jürgen Spitzmüller wrote: > Am Dienstag, dem 16.04.2024 um 12:08 +0200 schrieb Jean-Marc > Lasgouttes: > > I propose the following patch. Can you check that it works? > > Works for me with both testcases. Works well here. Thanks! Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
Am Dienstag, dem 16.04.2024 um 12:08 +0200 schrieb Jean-Marc Lasgouttes: > I propose the following patch. Can you check that it works? Works for me with both testcases. -- Jürgen -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
On 4/16/24 06:08, Jean-Marc Lasgouttes wrote: Le 13/04/2024 à 08:10, Jürgen Spitzmüller a écrit : Note that this is not specific to this particularly inset. I can reproduce with any other (text) inset, e.g.: 1. Start a new document. 2. Insert a Note inset 3. Save the (new) file (cursor still being in the Note inset). => Kaboom. What happens is that Save As... reloads the buffer (for a reason that is not very clear at this point), I think this is primarily because Save As... changes the filename, unlike just Save. I have some dim memory of discussion of this. Riki -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
Le 13/04/2024 à 08:10, Jürgen Spitzmüller a écrit : Note that this is not specific to this particularly inset. I can reproduce with any other (text) inset, e.g.: 1. Start a new document. 2. Insert a Note inset 3. Save the (new) file (cursor still being in the Note inset). => Kaboom. What happens is that Save As... reloads the buffer (for a reason that is not very clear at this point), which means that all cursors hold bad pointers. It seems that, before the biginset branch removed a few full metrics updates, we could get away with it (presumably some code somewhere fixes the cursors). Now, we have to fix it at the right place. I propose the following patch. Can you check that it works? JMarc From 3b51ab67228f1014432b99ac2037871bc45e1feb Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 16 Apr 2024 11:45:09 +0200 Subject: [PATCH] Sanitize cursors after a buffer has been reloaded When a buffer is reloaded, its content may remain the same, but the memory allocation is new, so that the inset pointers in cursors are now wrong. This requires to sanitize the cursors held by the buffer views. Before the biginset branch, some full metrics computation call that is now removed probably did that as a side effect. Now we have to be more precise. To this effect, introduce WorkAreaManager::sanitizeCursors() and use it in Buffer::reload(). --- src/Buffer.cpp| 2 ++ src/frontends/WorkArea.h | 7 +++ src/frontends/WorkAreaManager.cpp | 10 ++ src/frontends/WorkAreaManager.h | 2 ++ src/frontends/qt/GuiWorkArea.h| 4 ++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index bbe4d80589..c9d6818df6 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -5562,6 +5562,8 @@ Buffer::ReadStatus Buffer::reload() Buffer const * oldparent = d->parent(); d->setParent(nullptr); ReadStatus const status = loadLyXFile(); + // The inset members in cursors held by buffer views are now wrong. + workAreaManager().sanitizeCursors(); setBusy(false); if (status == ReadSuccess) { updateBuffer(); diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index d6912fc7fa..c0e673554a 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -18,6 +18,8 @@ namespace lyx { +class BufferView; + namespace frontend { /** @@ -40,6 +42,11 @@ public: /// Update window titles of all users. virtual void updateWindowTitle() = 0; + + /// + virtual BufferView & bufferView() = 0; + /// + virtual BufferView const & bufferView() const = 0; }; } // namespace frontend diff --git a/src/frontends/WorkAreaManager.cpp b/src/frontends/WorkAreaManager.cpp index 8d32c6b6d8..ed01be8997 100644 --- a/src/frontends/WorkAreaManager.cpp +++ b/src/frontends/WorkAreaManager.cpp @@ -13,6 +13,9 @@ #include "WorkAreaManager.h" +#include "BufferView.h" +#include "Cursor.h" + #include "Application.h" #include "WorkArea.h" @@ -69,6 +72,13 @@ void WorkAreaManager::scheduleRedraw() } +void WorkAreaManager::sanitizeCursors() +{ + for (WorkArea * wa : work_areas_) + wa->bufferView().cursor().sanitize(); +} + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/WorkAreaManager.h b/src/frontends/WorkAreaManager.h index 94c528b3a6..73548592fa 100644 --- a/src/frontends/WorkAreaManager.h +++ b/src/frontends/WorkAreaManager.h @@ -49,6 +49,8 @@ public: /// If there is no work area, create a new one in the current view using the /// buffer buf. Returns false if not possible. bool unhide(Buffer * buf) const; + /// Fix cursors in all buffer views held by work areas. + void sanitizeCursors(); private: typedef std::list::iterator iterator; diff --git a/src/frontends/qt/GuiWorkArea.h b/src/frontends/qt/GuiWorkArea.h index 148b79b73a..86bbfda939 100644 --- a/src/frontends/qt/GuiWorkArea.h +++ b/src/frontends/qt/GuiWorkArea.h @@ -59,9 +59,9 @@ public: /// is GuiView in fullscreen mode? bool isFullScreen() const; /// - BufferView & bufferView(); + BufferView & bufferView() override; /// - BufferView const & bufferView() const; + BufferView const & bufferView() const override; /// void scheduleRedraw(bool update_metrics) override; -- 2.40.1 -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
On Sat, Apr 13, 2024 at 08:10:59AM GMT, Jürgen Spitzmüller wrote: > Am Freitag, dem 12.04.2024 um 12:06 -0400 schrieb Scott Kostyshak: > > To reproduce: > > > > 1. Start a new document. > > 2. Start a math inset, e.g., ctrl + m. > > 3. Type "x". > > 4. Press "_" to go into the subscript. > > 5. Type "i" (so at this step the math will be $x_i$). > > 6. Save the (new) file. > > > > After saving, I get a SIGSEGV. > > > > Note that to reproduce, after 5, do not move the cursor. > > > > Can anyone reproduce? > > Yes. Seems the superscript inset is not properly initialized at that > point, leading to a null pointer in CursorSlice::text(). > > Note that this is not specific to this particularly inset. I can > reproduce with any other (text) inset, e.g.: > > 1. Start a new document. > 2. Insert a Note inset > 3. Save the (new) file (cursor still being in the Note inset). > > => Kaboom. Thanks for reproducing and the new (ore simple) recipe. Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master when saving with cursor in subscript
Am Freitag, dem 12.04.2024 um 12:06 -0400 schrieb Scott Kostyshak: > To reproduce: > > 1. Start a new document. > 2. Start a math inset, e.g., ctrl + m. > 3. Type "x". > 4. Press "_" to go into the subscript. > 5. Type "i" (so at this step the math will be $x_i$). > 6. Save the (new) file. > > After saving, I get a SIGSEGV. > > Note that to reproduce, after 5, do not move the cursor. > > Can anyone reproduce? Yes. Seems the superscript inset is not properly initialized at that point, leading to a null pointer in CursorSlice::text(). Note that this is not specific to this particularly inset. I can reproduce with any other (text) inset, e.g.: 1. Start a new document. 2. Insert a Note inset 3. Save the (new) file (cursor still being in the Note inset). => Kaboom. Backtrace: #0 0x0071be15 in lyx::CursorSlice::text() const (this=0x325d040) at /home/juergen/lyx/lyx-devel/src/CursorSlice.h:112 #1 lyx::DocIterator::innerTextSlice() const (this=0x2caf388) at DocIterator.cpp:216 #2 0x0071c231 in lyx::DocIterator::innerText() const (this=) at DocIterator.cpp:306 #3 0x00bae7ff in lyx::frontend::LayoutBox::updateContents(bool) (this=0x1e33db0, reset=reset@entry=false) at LayoutBox.cpp:581 #4 0x00b78bcb in lyx::frontend::GuiView::updateLayoutList() (this=this@entry=0x1dfcf30) at GuiView.cpp:2065 #5 0x00b78c2e in lyx::frontend::GuiView::setBusy(bool) (this=0x1dfcf30, busy=) at GuiView.cpp:1858 #6 0x00683212 in lyx::Buffer::setBusy(bool) const (this=this@entry=0x2680320, on=on@entry=false) at Buffer.cpp:4306 #7 0x006a010c in lyx::Buffer::reload() (this=this@entry=0x2680320) at Buffer.cpp:5565 -- Jürgen signature.asc Description: This is a digitally signed message part -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
SIGSEGV on current master when saving with cursor in subscript
To reproduce: 1. Start a new document. 2. Start a math inset, e.g., ctrl + m. 3. Type "x". 4. Press "_" to go into the subscript. 5. Type "i" (so at this step the math will be $x_i$). 6. Save the (new) file. After saving, I get a SIGSEGV. Note that to reproduce, after 5, do not move the cursor. Can anyone reproduce? Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master
On Sat, Mar 30, 2024 at 10:05:47AM +, José Matos wrote: > On Sat, 2024-03-30 at 10:16 +0100, Jürgen Spitzmüller wrote: > > Yes, fixed, thanks. > > I confirm, it works now for me. :-) Works here also, and I tested on my original (non-minimal) example. Thanks for the quick fix! Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master
On Sat, 2024-03-30 at 10:16 +0100, Jürgen Spitzmüller wrote: > Yes, fixed, thanks. I confirm, it works now for me. :-) -- José Abílio -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master
Am Freitag, dem 29.03.2024 um 22:38 -0400 schrieb Scott Kostyshak: > To reproduce: > > 1. Start a new document. > 2. Start a math inset and put "x + y". > 3. Select x. > 4. Press ctrl + f to open find. > 5. Press . > > The result for me is a SIGSEGV. > > Can anyone else reproduce? Yes, fixed, thanks. -- Jürgen signature.asc Description: This is a digitally signed message part -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master
Am Sat, 30 Mar 2024 08:10:53 + schrieb José Matos : > On Fri, 2024-03-29 at 22:38 -0400, Scott Kostyshak wrote: > > To reproduce: > > > > 1. Start a new document. > > 2. Start a math inset and put "x + y". > > 3. Select x. > > 4. Press ctrl + f to open find. > > 5. Press . > > > > The result for me is a SIGSEGV. > > > > Can anyone else reproduce? > > > > Scott > > Yes, this is the backtrace is attached. > Same here. Kornel pgpt4P6EXtiaZ.pgp Description: Digitale Signatur von OpenPGP -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
Re: SIGSEGV on current master
On Fri, 2024-03-29 at 22:38 -0400, Scott Kostyshak wrote: > To reproduce: > > 1. Start a new document. > 2. Start a math inset and put "x + y". > 3. Select x. > 4. Press ctrl + f to open find. > 5. Press . > > The result for me is a SIGSEGV. > > Can anyone else reproduce? > > Scott Yes, this is the backtrace is attached. -- José Abílio lyx: SIGSEGV signal caught! Sorry, you have found a bug in LyX, hope you have not lost any data. Please read the bug-reporting instructions in 'Help->Introduction' and send us a bug report, if necessary. Thanks! Bye. Error: LyX crashed! SIGSEGV signal caught! Sorry, you have found a bug in LyX, hope you have not lost any data. Please read the bug-reporting instructions in 'Help->Introduction' and send us a bug report, if necessary. Thanks! Bye. ( 1) src/lyx: lyx::frontend::Alert::doError(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool) ( 2) src/lyx: std::_Function_handler, std::allocator > const>, std::reference_wrapper, std::allocator > const>, std::reference_wrapper))(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool)> >::_M_invoke(std::_Any_data const&) ( 3) src/lyx: lyx::frontend::InGuiThread::synchronousFunctionCall() ( 4) src/lyx: lyx::frontend::IntoGuiThreadMover::callInGuiThread() ( 5) src/lyx: lyx::frontend::Alert::error(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool) ( 6) src/lyx: src/lyx() [0x77de5a] ( 7) /lib64/libc.so.6: /lib64/libc.so.6(+0x40710) [0x7f7d06453710] ( 8) src/lyx: lyx::CursorSlice::setPitPos(long, long) ( 9) src/lyx: lyx::InsetText::edit(lyx::Cursor&, bool, lyx::Inset::EntryDirection) ( 10) src/lyx: lyx::BufferView::setCursorSelectionTo(lyx::DocIterator const&) ( 11) src/lyx: lyx::findOne(lyx::BufferView*, std::__cxx11::basic_string, std::allocator > const&, bool, bool, bool, bool, bool, bool, bool, bool) ( 12) src/lyx: lyx::lyxfind(lyx::BufferView*, lyx::FuncRequest const&) ( 13) src/lyx: lyx::BufferView::dispatch(lyx::FuncRequest const&, lyx::DispatchResult&) ( 14) src/lyx: lyx::frontend::GuiView::dispatchToBufferView(lyx::FuncRequest const&, lyx::DispatchResult&) ( 15) src/lyx: lyx::frontend::GuiView::dispatch(lyx::FuncRequest const&, lyx::DispatchResult&) ( 16) src/lyx: lyx::frontend::GuiApplication::dispatch(lyx::FuncRequest const&, lyx::DispatchResult&) ( 17) src/lyx: lyx::frontend::GuiApplication::dispatch(lyx::FuncRequest const&) ( 18) src/lyx: lyx::dispatch(lyx::FuncRequest const&) ( 19) src/lyx: lyx::frontend::GuiSearchWidget::find(std::__cxx11::basic_string, std::allocator > const&, bool, bool, bool, bool, bool, bool) ( 20) src/lyx: lyx::frontend::GuiSearchWidget::doFind(bool, bool) ( 21) src/lyx: lyx::frontend::GuiSearchWidget::keyPressEvent(QKeyEvent*) ( 22) /lib64/libQt6Widgets.so.6: QWidget::event(QEvent*) ( 23) /lib64/libQt6Widgets.so.6: QApplicationPrivate::notify_helper(QObject*, QEvent*) ( 24) /lib64/libQt6Widgets.so.6: QApplication::notify(QObject*, QEvent*) ( 25) src/lyx: lyx::frontend::GuiApplication::notify(QObject*, QEvent*) ( 26) /lib64/libQt6Core.so.6: QCoreApplication::notifyInternal2(QObject*, QEvent*) ( 27) /lib64/libQt6Widgets.so.6: /lib64/libQt6Widgets.so.6(+0x1fb270) [0x7f7d07dfb270] ( 28) /lib64/libQt6Widgets.so.6: QApplicationPrivate::notify_helper(QObject*, QEvent*) ( 29) src/lyx: lyx::frontend::GuiApplication::notify(QObject*, QEvent*) ( 30) /lib64/libQt6Core.so.6: QCoreApplication::notifyInternal2(QObject*, QEvent*) ( 31) /lib64/libQt6Gui.so.6: QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) ( 32) /lib64/libQt6Gui.so.6: QWindowSystemInterface::sendWindowSystemEvents(QFlags) ( 33) /lib64/libQt6Gui.so.6: /lib64/libQt6Gui.so.6(+0x740824) [0x7f7d07940824] ( 34) /lib64/libglib-2.0.so.0: /lib64/libglib-2.0.so.0(+0x5c68c) [0x7f7d0690f68c] ( 35) /lib64/libglib-2.0.so.0: /lib64/libglib-2.0.so.0(+0xbd788) [0x7f7d06970788] ( 36) /lib64/libglib-2.0.so.0: /lib64/libglib-2.0.so.0(g_main_context_iteration+0x33) [0x7f7d06910b03] ( 37) /lib64/libQt6Core.so.6: QEventDispatcherGlib::processEvents(QFlags) ( 38) /lib64/libQt6Core.so.6: QEventLoop::exec(QFlags) ( 39) /lib64/libQt6Core.so.6: QCoreApplication::exec() ( 40) src/lyx: lyx::frontend::GuiApplication::exec() ( 41) src/lyx: lyx::LyX::exec(int&, char**) ( 42) src/lyx: src/lyx(main+0x45) [0x62248b] ( 43) /lib64/libc.so.6: /lib64/libc.so.6(+0x2a088) [0x7f7d0643d088] ( 44) /lib64/libc.so.6: /lib64/libc.so.6(__libc_start_main+0x8b) [0x7f7d0643d14b] ( 45) src/lyx: src/lyx(_start+0x25) [0x622385] [1]+ Aborted (core dumped) src/lyx -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel
SIGSEGV on current master
To reproduce: 1. Start a new document. 2. Start a math inset and put "x + y". 3. Select x. 4. Press ctrl + f to open find. 5. Press . The result for me is a SIGSEGV. Can anyone else reproduce? Scott signature.asc Description: PGP signature -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel