From mboxrd@z Thu Jan 1 00:00:00 1970 From: dje@watson.ibm.com To: gcc-gnats@gcc.gnu.org Subject: c++/4428: libgcc (unwind-dw2-fde.c) uses signed arithmetic for address comparison Date: Sun, 30 Sep 2001 12:56:00 -0000 Message-id: <20010930195209.4337.qmail@sourceware.cygnus.com> X-SW-Source: 2001-09/msg00592.html List-Id: >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: