On 2013-10-17 15:49, Lőrinczy Zsigmond wrote:
Hello,
my bash-3.2.48 (uses readline-6.2) on AIX computer produces stange
errors,
that I could trace back:
SIGWINCH->
signals.c:rl_sigwinch_handler ->
terminal.c:rl_resize_terminal ->
terminal.c:_rl_get_screen_size ->
shell.c:sh_set_lines_and_columns ->
libc:setenc ->
libc:putenv ->
libc: realloc
And finally realloc overwrites an unrelated data area (bash's
variables.c:export_env),
which causes bash to get SIGSEGV
My documentations suggest that one shouldn't call (directly or
indirectly) malloc/free/realloc from signal handler,
so I think there should be a way to let these setenv/putenv calls to
be delayed until the next readline-operation.
Yours: Lőrinczy Zsigmond
I hacked a quick-fix, that works for me: it checks the existence of
LINES and COLUMNS before changing them.
--- shell.cold 2010-07-25 23:40:06 +0200
+++ shell.c 2013-10-17 16:29:59 +0200
@@ -117,45 +117,47 @@
return (result);
}
/* Set the environment variables LINES and COLUMNS to lines and cols,
respectively. */
void
sh_set_lines_and_columns (lines, cols)
int lines, cols;
{
char *b;
+ if (getenv ("LINES") && getenv ("COLUMNS")) {
#if defined (HAVE_SETENV)
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", lines);
setenv ("LINES", b, 1);
xfree (b);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", cols);
setenv ("COLUMNS", b, 1);
xfree (b);
#else /* !HAVE_SETENV */
# if defined (HAVE_PUTENV)
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
sprintf (b, "LINES=%d", lines);
putenv (b);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
sprintf (b, "COLUMNS=%d", cols);
putenv (b);
# endif /* HAVE_PUTENV */
#endif /* !HAVE_SETENV */
+ }
}
char *
sh_get_env_value (varname)
const char *varname;
{
return ((char *)getenv (varname));
}
char *
sh_get_home_dir ()
{
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline