Skip to Content.
Sympa Menu

sm-discuss - [SM-Discuss] segfault in bc -l functions on x86_64 (with patch to fix)

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Seth Alan Woolley <seth AT tautology.org>
  • To: bug-bc AT gnu.org
  • Cc: sm-discuss AT lists.ibiblio.org
  • Subject: [SM-Discuss] segfault in bc -l functions on x86_64 (with patch to fix)
  • Date: Sat, 25 Jun 2005 00:23:59 -0700

I didn't see any patches to fix this on the web with google searching
and looking at a couple other distros, so I offer this bug report.

gdb bc
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".

(gdb) run -l
Starting program: /usr/bin/bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
a(1)

Program received signal SIGSEGV, Segmentation fault.
addbyte (byte=49 '1') at load.c:68
68 load.c: No such file or directory.
in load.c
(gdb) bt
#0 addbyte (byte=49 '1') at load.c:68
#1 0x000000000040741f in load_code (code=0x31 <Address 0x31 out of bounds>)
at load.c:346
#2 0x0000000000408d74 in generate (str=0x40d921 "1") at util.c:278
#3 0x0000000000403e2e in yyparse () at bc.y:542
#4 0x00000000004027f9 in main (argc=2, argv=0x7ffffffff9e8) at main.c:259
(gdb)

It appears to be a problem mixing ints and longs in places where the
saved functions are bandied about, so I changed them all to longs and it
works like a charm:

diff -Nuar bc-1.06/bc/bcdefs.h bc-1.06.works/bc/bcdefs.h
--- bc-1.06/bc/bcdefs.h 2000-09-13 11:23:20.000000000 -0700
+++ bc-1.06.works/bc/bcdefs.h 2005-06-24 23:37:35.000000000 -0700
@@ -100,8 +100,8 @@

/* Code addresses. */
typedef struct {
- int pc_func;
- int pc_addr;
+ long pc_func;
+ long pc_addr;
} program_counter;


diff -Nuar bc-1.06/bc/load.c bc-1.06.works/bc/load.c
--- bc-1.06/bc/load.c 2000-09-13 11:22:38.000000000 -0700
+++ bc-1.06.works/bc/load.c 2005-06-24 23:41:20.000000000 -0700
@@ -54,7 +54,7 @@
addbyte (byte)
char byte;
{
- int pc;
+ long pc;
bc_function *f;
char *new_body;

@@ -87,7 +87,8 @@
long lab;
{
bc_label_group *temp;
- int group, offset, func;
+ int group, offset;
+ long func;

/* Get things ready. */
group = lab >> BC_LABEL_LOG;
@@ -245,8 +246,8 @@
#if DEBUG > 2
printf ("var parameter number %d\n", ap_name);
#endif
- functions[(int)func].f_params =
- nextarg (functions[(int)func].f_params, ap_name,
+ functions[(long)func].f_params =
+ nextarg (functions[(long)func].f_params, ap_name,
TRUE);
}
else
@@ -255,8 +256,8 @@
#if DEBUG > 2
printf ("parameter number %d\n", ap_name);
#endif
- functions[(int)func].f_params =
- nextarg (functions[(int)func].f_params, ap_name,
+ functions[(long)func].f_params =
+ nextarg (functions[(long)func].f_params, ap_name,
FALSE);
}
}
@@ -269,8 +270,8 @@
#if DEBUG > 2
printf ("auto number %d\n", ap_name);
#endif
- functions[(int)func].f_autos =
- nextarg (functions[(int)func].f_autos, ap_name, FALSE);
+ functions[(long)func].f_autos =
+ nextarg (functions[(long)func].f_autos, ap_name, FALSE);
}
save_adr = load_adr;
load_adr.pc_func = func;

--
Seth Alan Woolley [seth at positivism.org], SPAM/UCE is unauthorized
Key id 00BA3AF3 = 8BE0 A72E A47E A92A 0737 F2FF 7A3F 6D3C 00BA 3AF3
Quality Assurance Team Leader; Security Team Member, Leader Emeritus
Linux so advanced, it may as well be magic http://www.sourcemage.org
Elected Coordinating Committee Member, Secretary, and Finances Chair
Pacific Green Party of Oregon - Peace - http://www.pacificgreens.org

Attachment: pgpnGWaaFD18Y.pgp
Description: PGP signature



  • [SM-Discuss] segfault in bc -l functions on x86_64 (with patch to fix), Seth Alan Woolley, 06/25/2005

Archive powered by MHonArc 2.6.24.

Top of Page