bug-ncurses
[Top][All Lists]
Advanced

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

Problem with ncurses (crash in tgetent()) ...


From: Andrzej Ostruszka
Subject: Problem with ncurses (crash in tgetent()) ...
Date: Wed, 11 Oct 2006 10:52:34 +0200

Hi all,

I've managed to boil down the problem to one simple file (pasted at
the end).  In a nut shell: whenever I start the thread which calls
tgetent() with stack size in the limits [4096, 8192] bytes (note
inclusive brackets) I get a segmentation fault.  Otherwise everything
is working OK.
I can't change the stack size in my target application (it's a
simulator for one board and all the code that will be loaded on it is
a production code out of my "jurisdiction").

This was observed via the readline library.  I originally had this
thread looping with call to readline() to get the next command to
execute - I've contacted the maintainer of the readline library and he
pointed me to ncurses library.  I've downloaded the latest ncurses and
the problem is also present there.

This is on:
$ uname -a
SunOS atena 5.9 Generic_118558-26 sun4u sparc SUNW,Netra-T12 Solaris
$ pagesize
8192

It looks to me like somewhere there is hardcoded that the pagesize is
4096 and this gives problems in this situation when it differs (just a
guess - but hopefully an educated one :)).  Examplary execution:

$ ./ncurses $((2**12-1))
tgetent() returned 1
^C
$ ./ncurses $((2**12))
zsh: segmentation fault (core dumped)  ./ncurses $((2**12))
$ ./ncurses $((2**13))
zsh: segmentation fault (core dumped)  ./ncurses $((2**13))
$ ./ncurses $((2**13+1))
tgetent() returned 1
^C

The backtrace just before the point where 'step' would give mi crash is:

Breakpoint 2, _nc_access (path=0xff211aa0 "/home/aao014/.terminfo/x/xterm",
   mode=4) at ../ncurses/./tinfo/access.c:94
94          if (access(path, mode) < 0) {
(gdb) bt
#0  _nc_access (path=0xff211aa0 "/home/aao014/.terminfo/x/xterm", mode=4)
   at ../ncurses/./tinfo/access.c:94
#1  0x00016364 in _nc_read_file_entry (
   filename=0xff211aa0 "/home/aao014/.terminfo/x/xterm", ptr=0x41988)
   at ../ncurses/./tinfo/read_entry.c:391
#2  0x0001714c in _nc_read_entry (
   tn=0xff211aa0 "/home/aao014/.terminfo/x/xterm", filename=0x41988 "",
   tp=0xff211630) at ../ncurses/./tinfo/read_entry.c:493
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0xff3cca5c in ?? ()

but I don't think that the problem is with the access() itself since
the same program with tgetent() replaced with access() with the
arguments as in the above backtrace has no problem.

The program itself is:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <curses.h>
#include <term.h>

void* thread_fun(void* dummy)
{
   int err = tgetent("", "xterm");
   printf("tgetent() returned %d\n", err);
   pause();
   return NULL;
}

int main(int argc, char* argv[])
{
  pthread_t tid;
  pthread_attr_t attrs;
  int stack = 4096;

  if (argc > 1)
      stack = strtol(argv[1], NULL, 0);

  pthread_attr_init(&attrs);
  pthread_attr_setstacksize(&attrs, stack);

  if (pthread_create(&tid, &attrs, thread_fun, NULL) != 0) {
      return -1;
  }

  pthread_join(tid, NULL);

  return 0;
}

Best regards
Andrzej




reply via email to

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