[gnu.gdb.bug] gdb seg fault

how@IVY.UCDAVIS.EDU (W. Wilson Ho) (07/18/89)

------- Start of forwarded message -------
From: crawford@iris (Rick Crawford)
To: debug@iris
Cc: crawford@iris
Subject: gdb 3.1 bug
Date: Thu, 13 Jul 89 18:31:34 pdt

Although the fix is easy (in signals_info() in infrun.c), it's still
disconcerting to find stuff like this:

  > iris:37%gdb
  > GDB 3.1, Copyright (C) 1988 Free Software Foundation, Inc.
  > There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
  > GDB is free software and you are welcome to distribute copies of it
  > under certain conditions; type "info copying" to see the conditions.
  > Type "help" for a list of commands.
  > (gdb) info sig 44
  > Number  Stop    Print   Pass to program Description
  > Segmentation fault
  > iris:38%

------- End of forwarded message -------

hrp@boring.cray.com (Hal Peterson) (07/25/89)

The same thing happens with 3.2 on a Sun-3 running SunOS 3.5.  The
problem (in 3.2, anyway) is that signals_info isn't doing a bounds
check on the signal number, and since there are only 32 signals, it
indexes off the end of the sys_siglist array.  Following my .signature
is a patch to fix it in 3.2.
-- 
Hal Peterson			Domain:  hrp@cray.com
Cray Research			Old style:  hrp%cray.com@uc.msc.umn.edu
1440 Northland Dr.		UUCP:  uunet!cray!hrp
Mendota Hts, MN  55120  USA	Telephone:  +1 612 681 3145
========================================================================
*** infrun-DIST.c       Wed Jul  5 14:46:07 1989
--- infrun.c    Mon Jul 24 12:37:50 1989
***************
*** 1223,1241 ****
       char *signum_exp;
  {
    register int i;
!   printf_filtered ("Number\tStop\tPrint\tPass to program\tDescription\n");

    if (signum_exp)
      {
        i = parse_and_eval_address (signum_exp);
!       printf_filtered ("%d\t", i);
!       printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No");
!       printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No");
!       printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No");
!       printf_filtered ("%s\n", sys_siglist[i]);
        return;
      }

    printf_filtered ("\n");
    for (i = 0; i < NSIG; i++)
      {
--- 1223,1251 ----
       char *signum_exp;
  {
    register int i;
!   register char *heading =
!     "Number\tStop\tPrint\tPass to program\tDescription\n";

    if (signum_exp)
      {
        i = parse_and_eval_address (signum_exp);
!       if ((i < NSIG) && (i >= 0))
!       {
!         printf_filtered (heading);
!         printf_filtered ("%d\t", i);
!         printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No");
!         printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No");
!         printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No");
!         printf_filtered ("%s\n", sys_siglist[i]);
!       }
!       else
!       {
!         error ("Invalid signal %d given as argument to \"info signal\"", i);
!       }
        return;
      }

+   printf_filtered (heading);
    printf_filtered ("\n");
    for (i = 0; i < NSIG; i++)
      {