Conversation
Put in a couple checks for bounds in front of every place I can imagine an out of bounds check is needed.
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
no crashing on selecting text, but also no text was selected just a bunch of newlines (mac os). In my terminal i see this: TTextEdit::getSelectedText(...) INFO - unexpectedly hit bottom of method so returning: "\n\n\n\n\n\n\n\n\n\n\n" that happens anytime i select anything, with various amounts of \n that seems related to how much i selected |
|
Oh, I wasn't smart with what I did. I chose to break out of the loop upon detecting a crash condition rather than continue. Thank you for pointing this out. Each time it did this \n it would have originally crashed. :( |
|
Never mind my previous statement. I used the wrong sign to check the bounds condition, so it always broke the loop when the variable was within the bounds. I had to stare at the code a long time to figure out what the sign should be. I'm getting confused in my old age. |
Fixed the signs, and moved code around to return on what would have caused the crash rather than just break out of a loop and never return the selected text.
|
@CriusMacOldenly so you think the issue was with blank lines in the selection? |
|
I think the issue was I used the wrong sign when trying to check for out of bounds. As a result, the code thought in bounds checks were out of bounds fails, and thus didn't actually run the code needed to copy the text. |
SlySven
left a comment
There was a problem hiding this comment.
👎 Unless my analysis is off the changes proposed here will have no effect other than wasting CPU cycles... 🙁
I think this undoes all my changes.
Undo final change.
|
This undoes all my suggested changes. The only way I can see the crash bug happening the way I tried to fix it, is if mudlet is running multithreaded, and mpBuffer can change while the code is within the function... which is crazy talk, I think. |
try catch blocks and variable dumps.
|
If this change doesn't work, we have problems. :( |
ℹ️ Technically, Mudlet does run multi-threadedly - (for instance, the Qt networking library code runs in a separate thread) - however the Mudlet part of it is effectively a single thread and the things that can modify the TBH I am not sure we have drilled down to the cause of the selection crash that you are investigating. I would note that there can be empty lines in the
// Start a new, but empty line in the various buffers
++localBufferPosition;
std::deque<TChar> newLine;
buffer.push_back(newLine);
lineBuffer.push_back(QString());
timeBuffer.push_back(QString());
promptBuffer << false;
dirty << true;so that calls to |
|
We have not drilled down to the cause of the crashes. I was instructed to fix the crashes with little knowledge of why the crashes were happening, and no way to reliably duplicate the crash. The best I can do is the try catch method I am suggesting, and I hope someone can send back the variable dump I've put in -- this'll at least explain why the crash is happening. Once I know why the crash is happening, I can better look at how to fix the crash. |
|
It looks like the MacOS builds failed. I don't know why though. :( |
|
Yeah - I'm getting the same error on a PR I have outstanding - seems (AFAICT) like we are trying to install a package (PCRE) which is already in the system - for this to cause a moan and error out instead of letting it through with a "package is already installed" warning I am guessing that we are trying to downgrade this - which is a bit odd... 😜 |
|
Maybe. I guess the homebrew environment changed, and what we had before was a pinned pcre version - because upgrading it took way too long due to all the dependencies. So the fix now is to pin to the current version that's already provided. |
Nope - it was a too simplistic shell script that was matching an updated brew for |
|
Okay have caused the macOs CI builds to rerun and they have passed now that development has been updated... |
Fix crash condition reported at Mudlet#3239 (comment) .
|
Crash condition described in #3239 (comment) which is caused by starting text selection on an empty line has now been fixed. |
|
Great - could you take out all the debugging code? Then we can out it into the release. |
Removed the debug code as per Vadi2's request in Mudlet#3241 (comment) .
As per your request, the debugging code has been removed. I really hope all the crash bugs are fixed. |
vadi2
left a comment
There was a problem hiding this comment.
Hopefully. Normal nature of rewrites though. :) thanks for fixing this! Appreciated!
* Update TTextEdit.cpp Put in a couple checks for bounds in front of every place I can imagine an out of bounds check is needed. * Update TTextEdit.cpp Fixed the signs, and moved code around to return on what would have caused the crash rather than just break out of a loop and never return the selected text. * Update TTextEdit.cpp I think this undoes all my changes. * Update TTextEdit.cpp Undo final change. * Update TTextEdit.cpp try catch blocks and variable dumps. * Update TTextEdit.cpp Fix crash condition reported at Mudlet#3239 (comment) . * Update TTextEdit.cpp Removed the debug code as per Vadi2's request in Mudlet#3241 (comment) .
Brief overview of PR changes/additions
Put in a couple checks for bounds in front of every place I can imagine an out of bounds check is needed.
Motivation for adding to Mudlet
Other info (issues closed, discussion etc)
Fix #3239.