From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27066 invoked by alias); 15 Nov 2002 21:19:16 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 26999 invoked from network); 15 Nov 2002 21:19:14 -0000 Received: from unknown (HELO dc-mx12.cluster1.charter.net) (209.225.8.22) by sources.redhat.com with SMTP; 15 Nov 2002 21:19:14 -0000 Received: from [66.189.46.2] (HELO platinum.local.) by dc-mx12.cluster1.charter.net (CommuniGate Pro SMTP 3.5.9) with ESMTP id 42303503; Fri, 15 Nov 2002 16:19:08 -0500 Date: Fri, 15 Nov 2002 13:19:00 -0000 Subject: Re: [RFA] Handle stack underflow in dbxread.c Content-Type: multipart/mixed; boundary=Apple-Mail-2--1041592686 Mime-Version: 1.0 (Apple Message framework v543) Cc: gdb-patches@sources.redhat.com To: Jim Blandy From: Klee Dienes In-Reply-To: Message-Id: X-SW-Source: 2002-11/txt/msg00426.txt.bz2 --Apple-Mail-2--1041592686 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 9 My bad: --Apple-Mail-2--1041592686 Content-Disposition: attachment; filename=check-context.txt Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="check-context.txt" Content-length: 2396 Index: buildsym.h =================================================================== RCS file: /cvs/src/src/gdb/buildsym.h,v retrieving revision 1.6 diff -u -r1.6 buildsym.h --- buildsym.h 8 Nov 2002 20:05:10 -0000 1.6 +++ buildsym.h 15 Nov 2002 20:47:34 -0000 @@ -22,6 +22,8 @@ #if !defined (BUILDSYM_H) #define BUILDSYM_H 1 +#include "gdb_assert.h" + /* This module provides definitions used for creating and adding to the symbol table. These routines are called from various symbol- file-reading routines. @@ -173,12 +175,6 @@ EXTERN int context_stack_size; -/* Macro "function" for popping contexts from the stack. Pushing is - done by a real function, push_context. This returns a pointer to a - struct context_stack. */ - -#define pop_context() (&context_stack[--context_stack_depth]); - /* Non-zero if the context stack is empty. */ #define outermost_context_p() (context_stack_depth == 0) @@ -271,6 +267,13 @@ extern void buildsym_init (void); extern struct context_stack *push_context (int desc, CORE_ADDR valu); + +/* Macro "function" for popping contexts from the stack. Pushing is + done by a real function, push_context. This returns a pointer to a + struct context_stack. */ + +#define pop_context() \ + (gdb_assert (context_stack_depth > 0), &context_stack[--context_stack_depth]); extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc); Index: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.36 diff -u -r1.36 dbxread.c --- dbxread.c 25 Oct 2002 22:25:55 -0000 1.36 +++ dbxread.c 15 Nov 2002 20:47:42 -0000 @@ -2774,6 +2774,13 @@ { /* This N_FUN marks the end of a function. This closes off the current block. */ + + if (context_stack_depth <= 0) + { + complain (&lbrac_mismatch_complaint, symnum); + break; + } + record_line (current_subfile, 0, function_start_offset + valu); within_function = 0; new = pop_context (); @@ -2842,6 +2849,12 @@ /* On most machines, the block addresses are relative to the N_SO, the linker did not relocate them (sigh). */ valu += last_source_start_addr; + + if (context_stack_depth <= 0) + { + complain (&lbrac_mismatch_complaint, symnum); + break; + } new = pop_context (); if (desc != new->depth) --Apple-Mail-2--1041592686 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 189 On Friday, November 15, 2002, at 03:02 PM, Jim Blandy wrote: > > The context in your first patch hunk doesn't appear anywhere in my > sources. Is this diff against the current sources? --Apple-Mail-2--1041592686--