Opened 3 years ago

Closed 3 years ago

Last modified 7 months ago

#7089 closed defect (fixed)

GUI: Crash in vector renderer when opening/closing console

Reported by: salty-horse Owned by: salty-horse
Priority: normal Component: GUI
Keywords: Cc:


When opening/closing the console repeatedly, it sometimes crashes. (See attached backtrace)

The issue happens in drawInteriorRoundedSquareAlg(). When it gets a small enough h, it goes through the the h>0 test.

h is then modified a few lines later:
h -= 2*Base::_strokeWidth;

Here it turns to 0 and causes the crash.

This can be easily guarded with another if(h<=0){return;} at that point.

However, I think there's another bug behind this:
strokeWidth is usually 0 when the console slides, so h shouldn't change by the above snipept.
In my crash (and tests where I slowed down the slide and printed the values), _strokeWidth was always 1. I'm not sure what caused it to change to 1.

Ticket imported from: bugs/7089.

Attachments (1)

backtrace.txt (2.7 KB) - added by salty-horse 3 years ago.

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by salty-horse

Attachment: backtrace.txt added

comment:1 Changed 3 years ago by lordhoto

I think it might be best to change the early check to assure w and h are bigger than the values subtracted at a later point. Or simply move the check further down below (if that doesn't cause other issues).

comment:2 Changed 3 years ago by salty-horse

The problem is with the scroll bar in the console, which uses a stroke >= 0.

To consistently get the error, type several "help" commands to get a scrollbar, before closing the console. You have to slow down the console sliding so it will always try to render the last few frames at the top of the screen:

--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -227,7 +227,7 @@ void ConsoleDialog::handleTickle() {
        if (_slideMode != kNoSlideMode) {
                const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration;
                if (_slideMode == kUpSlideMode) {
-                       _y = (int)(_h * (0.0 - tmp));
+                       _y -= 1;
                } else {
                        _y = (int)(_h * (tmp - 1.0));

So, do you think a good solution to move the if (w <= 0 || h <= 0) { return; }?
I don't like the idea of performing the calculation inside the test itself - IMO it should be kept simple.

comment:3 Changed 3 years ago by salty-horse

Owner: set to salty-horse
Resolution: fixed
Status: newclosed

comment:4 Changed 3 years ago by salty-horse

Fixed in 9b69b86f2972c93395ce6ee88f5566a31a05ce0d

comment:5 Changed 7 months ago by digitall

Component: GUI
Note: See TracTickets for help on using tickets.