This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/4428: libgcc (unwind-dw2-fde.c) uses signed arithmetic for address comparison
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4428: libgcc (unwind-dw2-fde.c) uses signed arithmetic for address comparison
- From: dje at watson dot ibm dot com
- Date: 30 Sep 2001 19:52:09 -0000
- Reply-To: dje at watson dot ibm dot com
>Number: 4428
>Category: c++
>Synopsis: libgcc (unwind-dw2-fde.c) uses signed arithmetic for address comparison
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Sep 30 12:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: dje@watson.ibm.com
>Release: gcc-3.0.x and gcc-3.1 (pre-release)
>Organization:
>Environment:
powerpc-ibm-aix4.3.3.0
>Description:
unwind-dw2-fde.c FDE comparison routines use signed
arithmetic on addresses. This is invalid when addresses
may have their most significant bit set, making large
addresses and differences between those values to generate
results which appear to be negative.
>How-To-Repeat:
static saddr
fde_unencoded_compare (struct object *ob __attribute__((unused)),
fde *x, fde *y)
{
return *(saddr *)x->pc_begin - *(saddr *)y->pc_begin;
}
Run till exit from #0 fde_unencoded_compare (ob=0x20000c40, x=0xf0105f8c,
y=0x2000087c) at /usr/gnu/src/gcc-3.0/gcc/unwind-dw2-fde.c:298
0xd0b962ec in search_object (ob=0x20000c40, pc=0x1000036f)
at /usr/gnu/src/gcc-3.0/gcc/unwind-dw2-fde.c:515
515 i1--;
Value returned is $63 = -1061592376
(gdb) print/x 0xd0b96608 - 0x10000340
$138 = 0xc0b962c8
(gdb) print (int) 0xd0b96608 - 0x10000340
$139 = -1061592376
>Fix:
Do not use shortcut of signed integer comparison for
addresses.
>Release-Note:
>Audit-Trail:
>Unformatted: