bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

core dump in torture test


From: Lucas Gonze
Subject: core dump in torture test
Date: Sat, 19 Oct 2002 16:02:48 -0400 (EDT)

Compile and run the enclosed code in a terminal -- I'm using konsole.  
Grab the right terminal border and resize back and forth, fast, about 20
times.

Crash.

In the following, the crash only occurs if the window has contents.  As it
stands there is a single label in the window.  If I remove the label the
crash goes away.  

...

Copy the following code to a file called TortureTestWindow.cpp.

Assuming your cdk install dir is /16G/shared_software/cdk-4.9.10/, build 
with:

gcc -g -DNCURSES -I/16G/shared_software/cdk-4.9.10/ 
-I/16G/shared_software/cdk-4.9.10//include 
-I/16G/shared_software/cdk-4.9.10//c++ TortureTestWindow.cpp -o 
test/torture -I -L/usr/lib/ -L/16G/shared_software/cdk-4.9.10/ -lcdk 
-lncurses -lm -lstdc++
...

Specs on my local environment:

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-108.7.2)

$ uname -a
Linux mandingo 2.4.9-34 #1 Sat Jun 1 06:25:16 EDT 2002 i686 unknown
...

Code:

// * For testing rapid and constant window size changes.  run the
// * program that comes from this, grab the border, and resize fast,
// * over and over again.

#include <iostream>
#include <curses.h>
#include <signal.h>

extern "C"
{
#include <cdk.h>
}

class TortureTestWindow {
 protected:
  WINDOW *cursesWin;
  int maxx, maxy;
  CDKSCREEN *cdkscreen;

  void init_screen(){

    getyx(cursesWin, maxy, maxx);

    cdkscreen = initCDKScreen(cursesWin);
    initCDKColor();

    char *txt[] = {"foo"};
    CDKLABEL *lbl = newCDKLabel (cdkscreen, CENTER, CENTER, txt, 1, FALSE, 
FALSE);
  }

 public:
  TortureTestWindow(){

    cursesWin = initscr();
    init_screen();
    refreshCDKScreen (cdkscreen);
  }

  void recalc_window(){

    if( !cdkscreen )
      return;

    // reinitialize the screen to match new coordinates
    destroyCDKScreen (cdkscreen);
    endCDK();
    init_screen();

    // redraw to pickup changes
    refreshCDKScreen(cdkscreen);

  }

  void wait_for_any_key(){

    while(true){
      switch( wgetch (cursesWin) ){
      case KEY_RESIZE:
        recalc_window();
        break;
      default:
        return;
      }
    }
  }

  ~TortureTestWindow(){
    destroyCDKScreen(cdkscreen);
    delwin (cursesWin);
    endCDK();
  }

};

TortureTestWindow *victim = NULL;
void winchange_handler(int signo){

  signal(SIGCHLD, SIG_IGN); // don't get stuck in a recursive call

  if( victim == NULL ){
    // not initialized yet, so there's no window to change
    signal(SIGWINCH, winchange_handler);
    return;
  }

  victim->recalc_window();
  signal(SIGWINCH, winchange_handler);
}

int main (int argc, char **argv){

  signal(SIGWINCH, winchange_handler);

  victim = new TortureTestWindow();
  victim->wait_for_any_key();  
  delete victim;
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]