[gnu.gdb.bug] core dump/internal error... with virtual functions

glenne@HPLSLA.HP.COM (Glenn Engel) (12/30/89)

Using gdb3.4.

When attempting to set breakpoints on virtual functions, I get 
various types of fatal errors.  Here's a gdb session:

Current directory is /tmp/
GDB 3.4, Copyright (C) 1989 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /tmp/a.out...done.
Type "help" for a list of commands.
(gdb) b Blob2::print
Reading in symbols for test.cc...done.
[0] cancel
[1] all
[2] file:test.cc; line number:20
[3] file:test.cc; line number:10
> 2
Breakpoint 1 at 0xc2: file test.cc, line 20.
(gdb) r
gdb internal error: *ap++ == MAGIC1

Inferior Gdb unknown (core dumped)

Here's the source code:


class Blob
{
public:
  int i;
  int j;

  Blob() {i = 1, j=2;};

  virtual void print() { printf("blob print\n"); };
};

class Blob2 : public Blob
{

public:
  static int i;
  virtual void print() ;
};
void Blob2::print() { printf("i=%d, j=%d\n",i,j); };

main()
{

Blob2 aBlob;
Blob2 anotherBlob;

aBlob.i = 99;
aBlob.print();
anotherBlob.print();
}

===========================================================================
The problem appears to be in symtab.c around line 1533

      sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*));
      physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*));

sym_arr and physnames are allocated with a length of 1 in this case but
then the code following the allocation proceeds to put data into more than
one element.  If I set a breakpoint on Blob2::print, I should not be
given the option of setting a breakpoint on Blob::print should I ?  Since
I uniquely specified the function I expected to just get a breakpoint only
at that function.

Also, the next code block uses alloca to allocate memory which is then used
outside of the code block.  Isn't use of alloca memory restricted to 
use within the scope of the block in which it was allocated ?

     physnames[i1] = (char*) alloca (strlen (phys_name) + 1);

--
Glenn 

 -------------------------------------------------
|          ___         |                          |
|         /  /         |     Glenn R. Engel       |
| HEWLETT/hp/PACKARD   |     glenne@hplsla.hp.com |
|       /__/           |     (206) 335-2066       |
|   Lake Stevens       |     NN7N                 |
| Instrument Division  |                          |
 -------------------------------------------------