Bug 9683 - 'ptype aClass()' crashes when inside a method of aClass
Summary: 'ptype aClass()' crashes when inside a method of aClass
Status: RESOLVED DUPLICATE of bug 9540
Alias: None
Product: gdb
Classification: Unclassified
Component: exp (show other bugs)
Version: 6.50
: P3 normal
Target Milestone: 6.8
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-24 16:20 UTC by Pedro Alves
Modified: 2010-01-25 16:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2008-12-24 16:20:30 UTC
While reproducing PR 9376, I noticed this GDB crash:

gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3), x86_64 GNU/Linux
GNU gdb (GDB) 6.8.50.20081224-cvs

$ cat 1783.cc

#include <stdlib.h>
#include <stdio.h>

class Sthread
{
public:
        int x ;
        int y ;
        Sthread() { printf ("Nice sthread\n") ;}

        ~Sthread() ;
        void test_sthread (void) ;
};

void Sthread::test_sthread (void)
{
  int i ;
  i = 10 ;
  i++ ;
  printf ("Value of I = %d\n", i) ;
}

int main ()
{
  class Sthread *newThr ;

  printf ("This code tests gdb type printing \n") ;
  newThr = new Sthread() ;

  newThr->test_sthread() ;

  return 0 ;
}

$ g++ 1783.cc -o 1783 -g3 -O0

>gdb --args ./gdb /home/pedro/1783
(top-gdb) r
Starting program: /home/pedro/gdb/baseline/build/gdb/gdb /home/pedro/1783
GNU gdb (GDB) 6.8.50.20081224-cvs
This GDB was configured as "x86_64-unknown-linux-gnu".
(gdb) start
Temporary breakpoint 1 at 0x40073d: file 1783.cc, line 27.
Starting program: /home/pedro/1783

Temporary breakpoint 1, main () at 1783.cc:27
27        printf ("This code tests gdb type printing \n") ;
(gdb) n
This code tests gdb type printing
28        newThr = new Sthread() ;
(gdb) s
Sthread (this=0x601010) at 1783.cc:9
9               Sthread() { printf ("Nice sthread\n") ;}
(gdb) ptype Sthread()

Program received signal SIGSEGV, Segmentation fault.


[Switching to Thread 0x7f0d427366e0 (LWP 23067)]
0x00000000004da69e in value_fn_field (arg1p=0x7fff4a75bc90, f=0xbf8c10, j=0,
type=0xbf88a0, offset=0)
    at ../../src/gdb/value.c:1482
1482          VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));

(top-gdb) p *sym
$2 = {ginfo = {name = 0xbf8910 "Sthread", value = {ivalue = 0, block = 0x0,
bytes = 0x0, address = 0, chain = 0x0},
    language_specific = {cplus_specific = {demangled_name = 0x0}}, language =
language_cplus, section = 0,
    obj_section = 0x0}, type = 0xbf88a0, symtab = 0xc17450, domain =
STRUCT_DOMAIN, aclass = LOC_TYPEDEF,
  is_argument = 0, line = 5, ops = 0x0, aux_value = 0x0, hash_next = 0xbf8d20}
(top-gdb) p SYMBOL_BLOCK_VALUE (sym)
$3 = (struct block *) 0x0
(top-gdb)
Comment 1 Tom Tromey 2010-01-25 16:35:48 UTC

*** This bug has been marked as a duplicate of 9540 ***