This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Patch for SIGSEGV in evaluate_subexp_standard


On Mon, Dec 10, 2001 at 10:44:21AM -0700, Fred Fish wrote:
> This example demonstrates a bug that is triggered when a C++ file is
> not compiled with -g.  Attached is a proposed patch to fix the
> problem.  I've regression tested the patch with the gdb testsuite and
> there are no regressions on an i686-pc-linux-gnu host.
> 
> ========================= Begin example =========================

> (gdb) ptype x2.asString()
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x08079937 in evaluate_subexp_standard (expect_type=0x0, exp=0x860d330, pos=0xbfffed04, noside=EVAL_AVOID_SIDE_EFFECTS) at /src/sourceware/gdb/src/gdb/eval.c:929
> 929		  struct type *ftype =
> (top-gdb) list
> 924		     a function call. This is here because people often want to
> 925		     call, eg, strcmp, which gdb doesn't know is a function.  If
> 926		     gdb isn't asked for it's opinion (ie. through "whatis"),
> 927		     it won't offer it. */
> 928	
> 929		  struct type *ftype =
> 930		  TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0]));
> 931	
> 932		  if (ftype)
> 933		    return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0])));
> (top-gdb) p argvec[0]
> $1 = (struct value *) 0x0
> (top-gdb) bt

> Here is the patch that fixes the bug.
> 
> 2001-12-10  Fred Fish  <fnf@redhat.com>
> 
> 	* values.c (value_fn_field): Add physname variable.  Use a minimal
> 	symbol if we don't find a full symbol.  Remove setting of the new
> 	value's type since that was already done by allocate_value().
> 	Remove obsolete commented out error call.

I think that the patch itself is fine (though I can not approve it). 
But could you either add a check for NULL at the call site, or perhaps
better add an error() like the commented out one in value_fn_field,
unless it is ever useful for value_fn_field to return NULL?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]