From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24299 invoked by alias); 28 Dec 2002 04:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24275 invoked by uid 71); 28 Dec 2002 04:26:01 -0000 Resent-Date: 28 Dec 2002 04:26:01 -0000 Resent-Message-ID: <20021228042601.24274.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, sunil.k.davasam@intel.com Received: (qmail 23949 invoked by uid 61); 28 Dec 2002 04:22:03 -0000 Message-Id: <20021228042203.23948.qmail@sources.redhat.com> Date: Fri, 27 Dec 2002 20:26:00 -0000 From: sunil.k.davasam@intel.com Reply-To: sunil.k.davasam@intel.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9076: Call Frame Instructions are not handled correctly during unwind operation.. X-SW-Source: 2002-12/txt/msg01333.txt.bz2 List-Id: >Number: 9076 >Category: libstdc++ >Synopsis: Call Frame Instructions are not handled correctly during unwind operation.. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Dec 27 20:26:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: sunil.k.davasam@intel.com >Release: gcc-3.2 >Organization: >Environment: $ g++ -v Reading specs from /local/skdavasa/gcc321/lib/gcc-lib/i386-redhat-linux/3.2.1/specs Configured with: gcc-3.2.1/configure --prefix=/local/skdavasa/gcc321 --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2.1 cat /etc/issue Red Hat Linux release 8.0 (Psyche) Kernel \r on an \m >Description: Based on DWARF2 Standard (6.4.2 Call Frame Instructions), The instructions "DW_CFA_undefined" & "DW_CFA_same_value" takes a single unsigned LEB128 argument that represents a register number. While executing these instructions, The runtime library is not treating the next data as operands to the "DW_CFA_undefined" & "DW_CFA_same_value" instructions. Instead, it treats them as opcodes and executes them. Due to this, the program behaviour changes and gives segmentation fault at runtime. This is not a problem when I use gcc compiler and libraries. Because, gcc compiler may not be generating "DW_CFA_undefined" & "DW_CFA_same_value" instructions. But, This is an interoperability issue. I tried to compile the testcase with intel compiler and linked with gcc libraries. I got segmentation fault. Fix for this problem may be simple. While handling "DW_CFA_undefined" & "DW_CFA_same_value" instructions (in file: gcc-3.2/gcc/unwind-dw2.c, function: execute_cfa_program), read the next LEB128 argument and ignore it. Please let me know, if it is not correct. Thanks, -Sunil. >How-To-Repeat: >Fix: file: gcc-3.2/gcc/unwind-dw2.c function: execute_cfa_program code: static void execute_cfa_program (const unsigned char *insn_ptr, const unsigned char *insn_end, struct _Unwind_Context *context, _Unwind_FrameState *fs) { .... .... switch (insn) { case DW_CFA_set_loc: insn_ptr = read_encoded_value (context, fs->fde_encoding, insn_ptr, (_Unwind_Ptr *) &fs->pc); break; case DW_CFA_advance_loc1: fs->pc += read_1u (insn_ptr) * fs->code_align; insn_ptr += 1; break; case DW_CFA_advance_loc2: fs->pc += read_2u (insn_ptr) * fs->code_align; insn_ptr += 2; break; case DW_CFA_advance_loc4: fs->pc += read_4u (insn_ptr) * fs->code_align; insn_ptr += 4; break; case DW_CFA_offset_extended: insn_ptr = read_uleb128 (insn_ptr, ®); insn_ptr = read_uleb128 (insn_ptr, &utmp); offset = (_Unwind_Sword) utmp * fs->data_align; fs->regs.reg[reg].how = REG_SAVED_OFFSET; fs->regs.reg[reg].loc.offset = offset; break; case DW_CFA_restore_extended: insn_ptr = read_uleb128 (insn_ptr, ®); fs->regs.reg[reg].how = REG_UNSAVED; break; 770 case DW_CFA_undefined: 771 case DW_CFA_same_value: 772 case DW_CFA_nop: 773 break; ..... ..... } Change the code in line numbers from 770 to 773 to the following.. case DW_CFA_undefined: case DW_CFA_same_value: insn_ptr = read_uleb128 (insn_ptr, ®); break; case DW_CFA_nop: break; ........ >Release-Note: >Audit-Trail: >Unformatted: