[Aptitude-devel] Bug#1148483: aptitude: Location of crash

Paul Martin pm at debian.org
Tue Sep 22 13:36:09 BST 2026


Package: aptitude
Version: 0.8.13-8.1
Followup-For: Bug #1148483

It's in the cwidget::toplevel::input_thread::dispatch() method:


    class input_thread
    {
...
      class get_input_event : public event
      {
...
        void dispatch()
        {
          // NB: use the GLOBAL getch function to avoid weirdness
          // referencing the state of toplevel.
          wint_t wch = 0;
          int status;

          bool done = false;

...
          // Tracks the error corresponding to the last read; used to
          // report errors to the user if we're unable to read a
          // keystroke.
          int last_read_error = 0;
          while(!done)
            {
              // Abort if the world went away underneath us.
              //
              // We need to check up here since we might have just
              // finished invoking a key handler, which could have
              // suspended cwidget.
              if(get_suspend_count() != my_suspend_count)
                return;

              // I assume here that init() set nodelay.
              do
                {
                  errno = 0;
                  status = get_wch(&wch);
                  last_read_error = errno;

                  if(status == KEY_CODE_YES && wch == KEY_RESIZE)
                    // Don't confuse resize events with EOF.
                    read_anything = true;
                } while(status == KEY_CODE_YES && wch == KEY_RESIZE);

              if(status == ERR) // No more to read.
                {
                  // Ignore signals caught during read() (EINTR) and
                  // beep at the user if there's a problem decoding a
                  // multibyte character.
                  if(last_read_error == EINTR)
                    read_anything = true;
                  else if(last_read_error == EILSEQ)
                    {
                      read_anything = true;
                      beep();
                    }

                  threads::mutex::lock l(m);
                  b = true;
                  c.wake_all();
                  done = true;
                }
              else
                {
...
                }
            }

          // If nothing was read (where "stuff being read" includes
          // resize keystrokes and interrupted system calls), kill the
          // main loop off.
          if(!read_anything)
            throw fatal_input_exception(last_read_error);
        }
      };


The get_wch() call is setting errno to EINVAL(22) "invalid argument".


I cannot reproduce this problem on a Raspberry Pi with a simple test 
program:

#define NCURSES_WIDECHAR 1
#include <curses.h>
#include <errno.h>

int main(void)
{
   wint_t wch = 0;

   WINDOW *w = initscr();
   mousemask(BUTTON1_PRESSED, NULL);

   errno = 0;
   int status = get_wch(&wch);
   int last_read_error = errno;

   endwin();

   printf("wch=%d status=%d errno=%d\n",
     wch, status, last_read_error);

   return 0;
}



More information about the Aptitude-devel mailing list