Fork us on GitHub Follow us on Facebook Follow us on Twitter

Opened 10 months ago

Closed 5 months ago

#838 closed defect (fixed)

tinput hits assertion failure if prompt runs off the screen

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone: 0.12.1
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:


tinput_read[_i]() will hit an assertion failure if we call it while the cursor is within str_length(prompt) characters from the end of the screen.

tinput_display() performs the following calculation, using current cursor coordinates col0, row0:

ti->prompt_coord = row0 * ti->con_cols + col0;
ti->text_coord = ti->prompt_coord + str_length(ti->prompt);

where ti→text_coord will be ≥ cols*rows and then in tinput_console_set_lpos():

       unsigned col = LIN_TO_COL(ti, lpos);
       unsigned row = LIN_TO_ROW(ti, lpos);
        assert(col < ti->con_cols);
        assert(row < ti->con_rows);

here we will have row ≥ ti→con_rows and hence the assert will fail.

An example of how to reproduce this is to create a program that purposefully puts the cursor to the bottom-right corner of the screen and then exists - at which point bdsh will try to print the prompt and it will abort.

Change History (2)

comment:1 Changed 8 months ago by Jiri Svoboda

Milestone: 0.12.1

comment:2 Changed 5 months ago by Jiri Svoboda

Resolution: fixed
Status: newclosed

The problem was that we did not account for scrolling while (initially) printing the prompt or the text. We computed the linear coordinate of text to be beyond the end of the screen and then assertion that the coordinate is within the screen failed.

Fixed in changeset f7a80521b3314c77b61a3a2ce80b11347ea69ce0.

Note: See TracTickets for help on using tickets.