bugLiberty Eiffel - Bugs: bug #61531, Error when compiling and running...

 
 

bug #61531: Error when compiling and running ncurses tutorial example menu.e

Submitter:  None
Submitted:  Tue 23 Nov 2021 12:12:11 PM UTC
   
 
Category:  Wrappers Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Confirmed
Assigned to:  None Open/Closed:  Open
Release:  None Fixed Release:  None
Planned Release:  curtiss
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 07 Mar 2022 09:37:03 PM UTC, comment #3: 

Thanks for this detailed analysis! So we should change the wrapper code accordingly. But is it also our duty to check with upstream ncurses project as the docs seem inconsistent and we'd need to adjust it again if the behavior is changed...

Raphael Mack <ramack>
Group administrator
Mon 07 Mar 2022 10:48:26 AM UTC, comment #2: 

The root cause is in sys/plugins/ncurses/c/ncurses.c, in C functions wgetwidth and wgetheight. it does not interpret properly the "maximum coordinates".

First, the actual assertion that is violated is missing in the attached reports (file #52329, file #52330 and file #52331). The reports are copied from terminal, but ncurses partially clears the screen the program exits. The real message can be seen by redirecting stderr to a file:

* Error at Run Time *: Ensure Assertion Violated.
* Error at Run Time *: Result > 0

The assertion "window /= Void" is caused by the GC disposing ncurses objects after the first assertion failure.

The real failure is in post-condition of function "witdh" from ncurses_window.e. It gives a negative window width.

Each sub-window in ncurses has 3 couples of values :

  1. top-left coordinates from parent window's origin
  2. top-left coordinates from screen's origin
  3. "maximum coordinates"


ncurses.c wrappers interpret "maximum coordinates" as right-down coordinates from parent window's origin.

It is actually the window's size, not related to the parent window's origin.

ncurses library and documentation contradict each other about what "maximum coordinates" are ("maximums of x and y, NOT window size" in comment in curses.h - the actual C code uses them as size).

The correction is just a change in the return line :
int wgetwidth(void* win) {
   int x, y;
   getmaxyx((WINDOW*)win, y, x);
   return x - wgetleft(win);
}

in :
int wgetwidth(void* win) {
   int x, y;
   getmaxyx((WINDOW*)win, y, x);
   return x;
}

and similarly with wgetheight.

That makes all ncurses examples work.

Note that, more generally, the sub-windows API in ncurses library (getmaxyx, derwin, mvderwin, mvwin) is not reliable at all :

  • subwindows are duplicated,
  • subwindows are not moved,
  • coordinates from parent window's origin and form screen origin's are not consistent,
  • etc.

Those bugs can be seen in "movewindow" example provided with ncurses library 6.3.

It seems that the ncurses subwindow management has evolved in an instable manner.

Patrick <pacl>
Tue 23 Nov 2021 09:19:41 PM UTC, comment #1: 

Thanks for reporting (on the mailing list and even more to put it here). In the high level view it looks like the class invariant in the ncurses wrapper is somehow wrong.

Raphael Mack <ramack>
Group administrator
Tue 23 Nov 2021 12:12:11 PM UTC, original submission:  

Compiling and then running the tutorial example ncurses/menu.e gives a run time error (see below and attached text file).

As per Rapha, compiling with -no_check means the example runs normally :).

My test system is Liberty Eiffel Bell on Slackware Linux 14.2, 64 bit version.

Note that the ncurses examples list.e and progressbar.e also gave runtime errors for me unless compiled with -no_check. See attached output text files attached.

Thanks very much, Aaron 

---
bash-4.3$ se compile menu.e -o menu
bash-4.3$ ./menu
12 frames in run-time stack.

Bottom of run-time stack

<system root>
Current = MENU#0x2077078
[ menubar = Void
  root_window = #0x2134558
]
...
<snip> (see attached text file for the full output)
...

Top of run-time stack

* Error at Run Time *: Class Invariant Violation.
* Error at Run Time *: window /= Void

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52329:  menu_example_output_2021_11_21.txt added by None (15KiB - text/plain)
file #52330:  list_example_output_2021_11_23.txt added by None (2KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pacl (Posted a comment)
  • -email is unavailable- added by ramack (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-23 ramack CategoryKernel libraries Wrappers
        StatusNone Confirmed
        Planned Releasebell curtiss
    2021-11-23 None Attached File- Added menu_example_output_2021_11_21.txt, #52329
        Attached File- Added list_example_output_2021_11_23.txt, #52330
        Attached File- Added progressbar_example_output_2021_11_23.txt, #52331

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code