🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8862

segv while printing pseudo-variable(?)

#8862
From: Robert Forsman
Date: Tue, 07 Jul 1992 14:35
337 lines
7319 bytes
  I was trying to make head+tail of a name list for a .o I was building and
decided to use gdb (since there isn't a stand-alone demangler yet).


wave:48 % gdb gdb
ld.so: warning: /usr/lib/libc.so.1.6.1 has older revision than expected 7
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
(gdb) run HashTable.o
Starting program: /local/bin/gdb HashTable.o
ld.so: warning: /usr/lib/libc.so.1.6.1 has older revision than expected 7
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
(gdb) info functions
All defined functions:

File HashTable.cc:
void HashTable::~HashTable();
struct HashTable *HashTable::HashTable();
void HashTable::choptail();
int HashTable::enter();
struct link *HashTable::index();
void HashTable::remove();
HType HashTable::retrieve();
(gdb) info var
All defined variables:

File HashTable.cc:
int TBLSIZE;
struct HashTableIndex index;
static PointSetType BOXY;
static PointSetType LIST;
(gdb) print BOXY

Program received signal 11, Segmentation fault
0x31324 in lookup_block_symbol (block=0x154010, name=0x0,
    namespace=VAR_NAMESPACE) at symtab.c:844
symtab.c:844: No such file or directory.
(gdb) where
#0  0x31324 in lookup_block_symbol (block=0x154010, name=0x0,
    namespace=VAR_NAMESPACE) at symtab.c:844
#1  0x3070c in lookup_symbol (name=0xf7fff420 "BOXY", block=0x154010,
    namespace=VAR_NAMESPACE, is_a_field_of_this=0x0, symtab=0x0)
    at symtab.c:500
#2  0x656a8 in c_lex () at ./c-exp.y:1394
#3  0x618f8 in c_parse () at bison.simple:228
#4  0x5d9ec in parse_exp_1 (stringptr=0xf7fff56c, block=0x0, comma=0)
    at parse.c:556
#5  0x5dad4 in parse_expression (string=0x13100e "BOXY") at parse.c:578
#6  0x2b1a4 in print_command_1 (exp=0x13100e "BOXY", inspect=0, voidprint=1)
    at printcmd.c:748
#7  0x2b3dc in print_command (exp=0x13100e "BOXY", from_tty=1)
    at printcmd.c:802
#8  0x3e1c in execute_command (p=0x13100e "BOXY", from_tty=1) at main.c:882
#9  0x40a0 in command_loop () at main.c:943
#10 0x3b84 in main (argc=2, argv=0xf7fff994) at main.c:820
(gdb)

 The preprocessed source for HashTable.o follows the command below that produced
it.  I don't expect it to be a working module, I just now got the syntax errors
out of it.

wave:56 % /cis/lightning2/thoth.aux/gcc-2.2.2/g++ -B/cis/lightning2/thoth.aux/
gcc-2.2.2/ -g -Wall -I. -I../../include -I../../depot/include -v -E HashTable.
cc > ! /tmp/shit
ld.so: warning: /usr/lib/libc.so.1.6.1 has older revision than expected 7
Reading specs from /cis/lightning2/thoth.aux/gcc-2.2.2/specs
gcc version 2.2.2
 /cis/lightning2/thoth.aux/gcc-2.2.2/cpp -lang-c++ -v -I. -I../../include -I..
/../depot/include -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun
 -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -g -Wall H
ashTable.cc
ld.so: warning: /usr/lib/libc.so.1.6.1 has older revision than expected 7
GNU CPP version 2.2.2 (sparc)

# 1 "HashTable.cc"
 

 
 
 

 
# 1 "HashTable.h" 1
 

 
 
 




#pragma interface

# 1 "PointSetBase.h" 1
 

 
 
 




#pragma interface

enum PointSetType {
  BOXY, LIST
};

class PointSetBase {
    PointSetType	tag;
public:
    virtual char equal(PointSetBase*) =0;
    virtual int hash_self(int) =0;
    PointSetType type() { return tag; }
};


# 12 "HashTable.h" 2


const int TBLSIZE=256;

 
typedef PointSetBase	*HType;

 
struct HashTableIndex {
    int	hashed;	 
    int	nth;	 
} index;

 

class HashTable {
private:
  struct link {
      link	*next;
      HType	data;
      int	refcount;
  };
  link *buckets[TBLSIZE];

   
  link *index(HashTableIndex);
  void choptail(int bucketnum);
public:
  HashTable() {
      for (int i=0; i<TBLSIZE; i++)
	  this->buckets[i] = 0;
  }
  ~HashTable() {
      for (int i=0; i<TBLSIZE; i++) {
	  link *scan=this->buckets[i];
	  while (scan) {
	      delete scan->data;
	      link *temp = scan;
	      scan = scan->next;
	      delete temp;
	  }
      }
  }
  int enter(HType, HashTableIndex &);
   
   
   

  HType retrieve(HashTableIndex);
   

  void remove(HashTableIndex);
   
   
};


# 8 "HashTable.cc" 2


#pragma implementation

int HashTable::enter(HType val, HashTableIndex &rval)
{
    rval.hashed = val->hash_self(TBLSIZE);
    rval.nth = 0;

     
    link	**scan;
    link	*blanklink;
    int		blankidx;

    blanklink=0;
    for (scan = &this->buckets[rval.hashed];
	 *scan;
	 scan = &(*scan)->next) {
	if (!(*scan)->data) {
	     
	    blanklink = *scan;
	    blankidx = rval.nth;
	} else {
	     
	     
	    if ((*scan)->data->equal(val))
		 
		break;

	     
	}
	rval.nth++;
    }
     
     
     
     
     
     

    link	*target;
    int	was_there;	 

    if (! *scan) {
	if (blanklink) {
	     
	     
	    target = blanklink;
	    rval.nth = blankidx;
	} else {
	     
	     
	    target = *scan = new link;
	    target->next = 0;
	    target->refcount = 0;
	     
	}
	 
	 

	target->data = val;
	was_there = 0;	 
    } else {
	target = *scan;
	 
	was_there = 1;	 
    }

    target->refcount++;

    return was_there;
}








HashTable::link *HashTable:: index(HashTableIndex idx)
{
    link	*scan;
    int	i;

     
	;

    for (scan = this->buckets[idx.hashed], i=0;
	 i<idx.nth  ;
	 scan = scan->next)
	;

     
	;

    return scan;
}

HType HashTable:: retrieve(HashTableIndex idx)
{
    return this->index(idx)->data;
}

void HashTable:: choptail(int bucketnum)
{
    link	**scan, **lastblank;

    lastblank = 0;
    scan = &this->buckets[bucketnum];

    while (*scan) {
	if ((*scan)->data) {
	     
	    lastblank = 0;
	} else if (!lastblank) {
	     
	    lastblank = scan;
	}
    }
     
     

    if (lastblank) {
	link	*temp1, *temp2;
	 
	 
	temp1 = *lastblank;
	*lastblank = 0;

	 
	while (temp1) {
	    temp2 = temp1;
	    temp1 = temp1->next;
	    delete temp2;
	}
    }
}

void HashTable:: remove(HashTableIndex idx)
{
    link	*target;
    target = this->index(idx);

    target->refcount--;

    if (target->refcount)
	return;

    delete target->data;
    target->data = 0;

    this->choptail(idx.hashed);
}
Technical Details
Message-ID: <9207071435.AA29904@life.ai.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!reef.cis.ufl.edu!thoth

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,8263332981837d70,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-07-07 16:02:40 PST
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!reef.cis.ufl.edu!thoth
From: thoth@reef.cis.ufl.edu (Robert Forsman)
Subject: segv while printing pseudo-variable(?)
Message-ID: <9207071435.AA29904@life.ai.mit.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 7 Jul 1992 14:35:13 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 339