delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/10/21:50:24

From: "Christo Fogelberg" <doubtme AT hotmail DOT com DOT nospam>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with Ctor/Dtor.
Date: Sat, 11 Sep 1999 12:43:06 +1200
Organization: The Internet Group (Dunedin)
Lines: 176
Message-ID: <937011029.69620@Chaos.es.co.nz>
NNTP-Posting-Host: news.dun.ihug.co.nz
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Cache-Post-Path: Chaos.es.co.nz!unknown AT p7-max7 DOT dun DOT ihug DOT co DOT nz
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all... I am having a problem with a templated class, holding a vector of
type T.

Basically, two problems:
1) When the class is destructed, the program crashes.
2) If, for some bizarre reason, a string with an extension (.dat) is
entered, then the program crashes on constructing the database.

What makes it even weirder is that #2 just popped up recently (not sure
about #1) previous versions worked fine?!

I am unsure of how much code I should post, so will post the symdumps, ctor
and dtor for now, and if I need to/should post more, please tell me :)

Thanks in advance for helping with what is probably a very stupid error :)

Christo

CODE/SYMDUMPS:

For problem number 1:

Three symifies, all with different results (normal? not normal?)

##############################################

Exiting due to signal SIGILL
Invalid Opcode at eip=00000018
eax=00000009 ebx=000b2dbc ecx=00000008 edx=00032a2a esi=00000056
edi=00032b25
ebp=000b2afd esp=000b2af1 program=C:\DJGPP\DATABASE\DATABA~1.EXE
cs: sel=00af  base=835c4000  limit=000bffff
ds: sel=00b7  base=835c4000  limit=000bffff
es: sel=00b7  base=835c4000  limit=000bffff
fs: sel=0087  base=0000ef60  limit=0000ffff
gs: sel=00c7  base=00000000  limit=0010ffff
ss: sel=00b7  base=835c4000  limit=000bffff
App stack: [000b2b24..00032b24]  Exceptn stack: [00032a00..00030ac0]

Call frame traceback EIPs:
  0x00000018   0x18
  0x00000140   0x140

##############################################

Exiting due to signal SIGSEGV
General Protection Fault at eip=00000014
eax=00000009 ebx=000b2dbc ecx=00000006 edx=00032a28 esi=00000054
edi=00032b24
ebp=000b2afc esp=000b2ae4 program=C:\DJGPP\DATABASE\DATABA~1.EXE
cs: sel=00af  base=835c4000  limit=000bffff
ds: sel=00b7  base=835c4000  limit=000bffff
es: sel=00b7  base=835c4000  limit=000bffff
fs: sel=0087  base=0000ef60  limit=0000ffff
gs: sel=00c7  base=00000000  limit=0010ffff
ss: sel=00b7  base=835c4000  limit=000bffff
App stack: [000b2b24..00032b24]  Exceptn stack: [00032a00..00030ac0]

Call frame traceback EIPs:
  0x00000014   0x14
  0x00014020   ___djgpp_exception_table

##############################################

This one was after recompiling and a minor change to an unrelated function
(a search function)

Exiting due to signal SIGSEGV
General Protection Fault at eip=00008366
eax=5e5be465 ebx=00000000 ecx=00014456 edx=fe040800 esi=00000011
edi=00000020
ebp=00014476 esp=000b2af8 program=C:\DJGPP\DATABASE\DATABA~1.EXE
cs: sel=00af  base=835dc000  limit=000bffff
ds: sel=00b7  base=835dc000  limit=000bffff
es: sel=00b7  base=835dc000  limit=000bffff
fs: sel=0087  base=0000ef60  limit=0000ffff
gs: sel=00c7  base=00000000  limit=0010ffff
ss: sel=00b7  base=835dc000  limit=000bffff
App stack: [000b2b24..00032b24]  Exceptn stack: [00032a00..00030ac0]

Call frame traceback EIPs:
  0x00008366   ___8ofstreamiPCcii+226

##############################################

For problem number 2, just one symify - all were the same.

Exiting due to signal SIGSEGV
General Protection Fault at eip=000147bc
eax=746164fe ebx=000b2db0 ecx=000b2db0 edx=00032d48 esi=000b2db8
edi=000000c8
ebp=000b29d4 esp=000b29c8 program=C:\DJGPP\DATABASE\DATABA~1.EXE
cs: sel=00a7  base=835f6000  limit=000bffff
ds: sel=00af  base=835f6000  limit=000bffff
es: sel=00af  base=835f6000  limit=000bffff
fs: sel=0087  base=0000ef60  limit=0000ffff
gs: sel=00c7  base=00000000  limit=0010ffff
ss: sel=00af  base=835f6000  limit=000bffff
App stack: [000b2b24..00032b24]  Exceptn stack: [00032a00..00030ac0]

Call frame traceback EIPs:
  0x000147bc   _free+172
  0x00004339   _deallocate__t23__malloc_alloc_template1i0PvUl+17, line 158
of da
tabase2.cppd
  0x000042a1
_deallocate__t12simple_alloc2Z8TestDataZt24__default_alloc_templa
te2b0i0P8TestDataUl+29, line 224 of database2.cpp
  0x00004238   __$_t6vector2Z8TestDataZt24__default_alloc_template2b0i0+32,
line
 126 of database2.cpp
  0x000020d9   _main+653, line 98 of database2.cpp
  0x0001401a   ___crt1_startup+174

###############################################

The constructor:

DataBase<T>::DataBase()
{
        vector<T> itsDataList;
        itsDataList.reserve(50);
        it = itsDataList.begin();
}

##############################################

The destructor:

// Destructor. Something is wrong with it.
template <class T>
DataBase<T>::~DataBase()
{
        // Stubbed for later use.
}

##############################################

Also, just thinking of it, the class declaration:

template <class T>
class DataBase
{
 public:
        // Constructors, Destructors
        DataBase();
        DataBase(const DataBase& rhs);
        ~DataBase();

        // Accessors

        // Other Methods
        void Display();
        void Display(int offset);
        void Search();
        void Save(String& theFileName);
        void Resave(String& theFileName);
        void Load(String& theFileName);
        void Reload(String& theFileName);
        void Delete();
        void Delete(int entry);
        void New();
        void Edit();
        void Edit(int entry);

 private:
        // Contained Datalist:
        vector<T> itsDataList;
        vector<T>::iterator it;

        // Private Functions:
        void Remove(T& theData);
        int GetEntry();
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019