This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Previously reported g++ bug (dated March 28th 2000)


Hi,
 
Sorry to send this query to the bug reporting address, but I can't find any evidence that my bug report (sent on the 28th March 2000) has been received at all - it certainly hasn't been fixed yet (I've tested using the on-line compiler at 'www.codesourcery.com/gcc-compile.html'). The bug report was sent to email address 'bug-g++@prep.ai.mit.edu' as directed in the instructions for bug reporting that came with the gcc source. I've included the entire bug report again here. Is it possible for someone to mail me please when this report has been allocated to someone for fixing..?? Thanks!
 
BUG REPORT
 
Hi,
 
I believe we have run into a bug with the gcc compiler [version 2.95.2 19991024 (release) under RedHat Linux release 5.2, kernel version 2.0.36 with binutils version 2.9.1.0.15] related to when constructors/destructors are called. It seems that under certain circumstances, an argument passed to a function does not have its copy constructor called at function call time (allowed under ANSI) but that its destuctor _does_ get called when the function returns, leading to an imbalance of CTORs/DTORs. We came accross the problem when attempting to build an application developed under Microsoft VC++ 6 on WindowsNT. The application has been written as near as we can be sure to be 100% ANSI complient and the Microsoft built version works reliably under NT. In our application, we use reference counting to keep memory usage to a minimum, and it is because of this that we hit the problem I am now reporting - the use count of an object hits zero, it's memory get freed, and the next access, that ought to be legal, causes a segmentation fault because the object has been deleted. We have put together an example that illustrates the problem (attached). We have also been able to find a workaround that proves the problem in one case (compiling the example with -DWORKAROUND demonstrates this). We would be grateful if someone could find the problem in the GCC compiler, and are willing to test any patch produced. Note: We are not keen on using our 'workaround' in the whole of our application since we do not know where else in the code the bug might manifest itself. Thank You!
 
INSTRUCTIONS FOR BUILDING THE EXAMPLE
 
To build the example that shows-up the problem (too many DTORs getting called), use command line:
  g++ -O0 DtorBug.cpp
and run a.out;
 
To build the example that proves that the above illustrates a bug (implements a workaround), use command line:
  g++ -O0 DtorBug.cpp -DWORKAROUND
and run a.out;
 
RUNNING THE EXAMPLE
 
On running the example that shows up the problem, you will note that the use count reported at the point of the last 'Hndl' copy CTOR is 2, but that 3 Hndl DTORs get called (the last one when the use-count is already zero!).
 
On running the example with the 'work-around', you will note that the last use-count reported is 3, and that 3 DTORs get called correctly. The only difference between in the code is that the function 'appendToMembers(..)' is called with a temporary object, pre-initialized (see lines 270 to 277).
 
GCC INSTALL NOTES
 
I did not pass any options to 'configure' when installing gcc.
 
END.

DtorBug.cpp


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