Closed QMeqGR closed 2 months ago
Here is a simple example where I can get it to crash reproducibly. In the first screenshot there is an error cell in red. Some combination of clicking below this cell and then clicking above it will result in the white horizontal line in cell 2, that's where the black horizontal cursor is located but not shown. Then hitting the delete key results in the second screenshot where the first cell is highlighted in blue. Hitting the delete key again triggers the error.
I was able to reproduce it - but I do not see, where is the issue in the code. But easy to reproduce: Create some cells. Delete the last one. Click with the mouse pointer below the latest cell - the cursor is in a position with some space between the last cell and the cursor position. Hit backspace twice -> crash. But why is the cursor positioned too low?
I don't know, but following your example I created a lot of cells, about 15. Then delete all the way back up to say 2 cells. Then click way down on the page and the cursor goes below where all of the deleted cells were. Maybe this provides some clue. Does the cursor think the cells are still there?
Still trying to reproduce the problem on my computer: I believe it could show me the source of more than one problem.
Perhaps the cursor was placed after the deleted cell it believes to belong to and therefore is placed this low...
This can be reproduced by the following inputs:
1 [shift-enter] (create a math cell)
2 [shift-enter] (create another math cell)
[backspace][backspace] (mark the latest input/output cell and delete it)
(click with the mouse-cursor in the lower part of the worksheet.
There is a gap between the (left over) (i1) / (o1) cell and the new created horizontal cursor)
[backspace][backspace] --> crash
The cursor should be positioned after the (left over) (i1)/(o1)
cell, but occurs after the position of the deleted cell.
On my computer it still doesn't crash. But all your work on finding the trigger all pointed to the same direction => let's try a speculative fix.
I still get a crash, this time with the backtrace below.
ASSERT INFO: /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp(3056): assert "m_tree.get() == tornOut.cell" failed in DeleteRegion().
BACKTRACE:
[1] Worksheet::DeleteRegion(GroupCell, GroupCell, std::__cxx11::list<Worksheet::TreeUndoAction, std::allocator
That seems to fix it. Thank you.
Blind coding is always a bit scary. And thanks for your bug report. If the problem ever shows up again feel free to reopen this ticket or to write a new one, if you prefer to.
Thanks Gunter for solving the issue!
I'm using version 24.02.2. I can generate a crash by mouse clicking below all cells in an empty part of the window, and then using the up arrow or delete buttons. It seems to get hung up on the last cell and then the crash dialog appears. I don't know that this will produce the crash 100% of the time, but this has happened frequently over the last few weeks.
Here is the backtrace from the dialog:
ASSERT INFO: /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp(3103): assert "m_tree.get() == tornOut.cell" failed in DeleteRegion().
BACKTRACE: [1] Worksheet::DeleteRegion(GroupCell, GroupCell, std::__cxx11::list<Worksheet::TreeUndoAction, std::allocator >) /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp:3103
[2] Worksheet::DeleteRegion(GroupCell, GroupCell) /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp:3063
[3] Worksheet::DeleteSelection() /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp:2932
[4] wxMaxima::EditMenu(wxCommandEvent&) /home/packages/SOURCE/wxmaxima/src/wxMaxima.cpp:6292
[5] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler, wxEvent&)
[6] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[7] wxEvtHandler::TryHereOnly(wxEvent&)
[8] wxEvtHandler::DoTryChain(wxEvent&)
[9] wxEvtHandler::ProcessEvent(wxEvent&)
[10] wxWindowBase::ProcessWindowEvent(wxEvent&) /usr/include/wx-3.2/wx/window.h:885
[11] Worksheet::OnKeyDown(wxKeyEvent&) /home/packages/SOURCE/wxmaxima/src/Worksheet.cpp:3318
[12] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[13] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[14] wxEvtHandler::TryHereOnly(wxEvent&)
[15] wxEvtHandler::ProcessEventLocally(wxEvent&)
[16] wxEvtHandler::ProcessEvent(wxEvent&)
[17] wxScrollHelperEvtHandler::ProcessEvent(wxEvent&)
[18] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[19] g_closure_invoke
[20] g_signal_emit_valist
[21] g_signal_emit
[22] gtk_window_propagate_key_event
[23] g_closure_invoke
[24] g_signal_emit_valist
[25] g_signal_emit
[26] gtk_main_do_event
[27] g_main_loop_run
[28] gtk_main
[29] wxGUIEventLoop::DoRun()
[30] wxEventLoopBase::Run()
[31] wxAppConsoleBase::MainLoop()
[32] MyApp::OnRun() /home/packages/SOURCE/wxmaxima/src/main.cpp:480
[33] CommonMain() /home/packages/SOURCE/wxmaxima/src/main.cpp:88
[34] main /home/packages/SOURCE/wxmaxima/src/main.cpp:159
[35] __libc_start_main
[36] _start