Thread View: comp.sys.hp.hpux
6 messages
6 total messages
Started by Michael Bresnahan
Sat, 04 Nov 1995 21:29
Bug in CC exception handling?
Author: Michael Bresnahan
Date: Sat, 04 Nov 1995 21:29
Date: Sat, 04 Nov 1995 21:29
140 lines
3546 bytes
3546 bytes
This simple program illustrates what looks like a bug in the exception handling
stack unwinding code of HP's CC/libCC or there is something about C++ I don't
understand. It shows the same object being destructed twice, and one object
left hanging. I am using:
CC: HP C++ HPCPLUSPLUS A.03.70
libC: HP C++ HPCPLUSPLUS A.03.70
OS: HP-UX devux01 A.09.04 B 9000/891 342319241 16-user license
I have one base object Dbbase and two derived objects from it, Dbctx and
Dbconn. The program creates a Dbctx object and then calls the member function
connect(). This function is supposed to return a Dbconn object, however the
constructor for Dbconn throws an exception. The stack is unrolled, but instead
of destructing the base object of the partially constructed dbconn object, the
base object of the Dbctx object is destructed. Then the base object of Dbctx
is destructed again when the Dbctx object is destructed. Is this making any
sense? Hopefully the code and output will speak for itself.
Here is the code:
#include <iostream.h>
#include <stdlib.h>
class Dbconn;
class my_ex { };
class Dbbase {
protected:
Dbbase();
virtual ~Dbbase();
private:
char* data;
};
class Dbctx : public Dbbase {
public:
// Construction
Dbctx();
// Destruction
virtual ~Dbctx();
Dbconn connect();
};
class Dbconn : public Dbbase {
public:
Dbconn();
virtual ~Dbconn();
};
int main() {
try {
Dbctx ctx;
Dbconn conn = ctx.connect();
}
catch( my_ex& ex) {
cout << "Exception caught!" << endl;
exit(1);
}
}
Dbbase::Dbbase() {
cout << "Dbbase(): " << this << endl;
data = new char[8192];
cout << "\tdata: " << (void*)data << endl;
}
Dbbase::~Dbbase() {
cout << "~Dbase(): " << this << endl;
cout << "\tdata: " << (void*)data << endl;
delete data;
}
Dbctx::Dbctx() : Dbbase() {
cout << "Dbctx(): " << this << endl;
}
Dbctx::~Dbctx() {
cout << "~Dbctx(): " << this << endl;
}
Dbconn Dbctx::connect() {
return Dbconn();
}
Dbconn::Dbconn() : Dbbase() {
cout << "Dbconn(): " << this << endl;
throw my_ex();
}
Dbconn::~Dbconn() {
cout << "~Dbconn: " << this << endl;
}
Here is how I compiled it:
CC bug.cc +eh -o bug
And here is the ouput:
Dbbase(): 0x7b03350c
data: 0x40008000
Dbctx(): 0x7b03350c
Dbbase(): 0x7b033514
data: 0x4000a008
Dbconn(): 0x7b033514
~Dbase(): 0x7b03350c // This should be 0x7b033514
data: 0x40008000 // This should be 0x4000a008
~Dbctx(): 0x7b03350c
~Dbase(): 0x7b03350c
data: 0x40008000
Exception caught!
Note that the Dbctx object at 0x7b03350c gets freed twice and the Dbconn object
is left floating. Am I missing something or is this a bug in HP's code? This
is holding my project up. I may have to forego the use of exceptions and use a
more traditional error handling mechanism.
MikeB
Re: Bug in CC exception handling?
Author: Ethan Shayne
Date: Mon, 06 Nov 1995 04:24
Date: Mon, 06 Nov 1995 04:24
27 lines
1587 bytes
1587 bytes
I haven't had a chance to look at your specific example, but yes, there are some exception handling bugs in the 3.70 version of the HP C++ compiler which do involve objects being destroyed twice in some cases. I'm told by the HP people that there are actually a few separate exception handling bugs which all show the same basic symptoms (i.e. objects being destroyed twice). Many have been fixed and these fixes are included in the latest patches which are already available. You may want to try installing those. Others (like the one we ran into) are not fixed by those patches, but are fixed in a patch which I'm told should be available within the next week. Ethan Shayne eshayne@ibm.net Michael Bresnahan <mbresnahan1@mmm.com> wrote: >This simple program illustrates what looks like a bug in the exception handling >stack unwinding code of HP's CC/libCC or there is something about C++ I don't >understand. It shows the same object being destructed twice, and one object >left hanging. I am using: >CC: HP C++ HPCPLUSPLUS A.03.70 >libC: HP C++ HPCPLUSPLUS A.03.70 >OS: HP-UX devux01 A.09.04 B 9000/891 342319241 16-user license
Re: Bug in CC exception handling?
Author: Michael Bresnahan
Date: Mon, 06 Nov 1995 07:19
Date: Mon, 06 Nov 1995 07:19
16 lines
1316 bytes
1316 bytes
eshayne@ibm.net (Ethan Shayne) wrote: I'm told by the HP people that there are actually a few separate >exception handling bugs which all show the same basic symptoms (i.e. >objects being destroyed twice). Many have been fixed and these fixes >are included in the latest patches which are already available. You >may want to try installing those. Others (like the one we ran into) >are not fixed by those patches, but are fixed in a patch which I'm >told should be available within the next week. Thanks! Its good to know I am not alone in these problems and even better to hear that there are patches available. Do you or anyone else know the number's of these patches? MikeB
Re: Bug in CC exception handling?
Author: Oisin Hurley
Date: Tue, 14 Nov 1995 10:33
Date: Tue, 14 Nov 1995 10:33
22 lines
1380 bytes
1380 bytes
eshayne@ibm.net (Ethan Shayne) writes: [elided] >I'm told by the HP people that there are actually a few separate >exception handling bugs which all show the same basic symptoms (i.e. >objects being destroyed twice). Many have been fixed and these fixes >are included in the latest patches which are already available. Can any HP people here drop a few pointers to the location of a description of these bugs plus associated patches? Has the old no +eh with +Z feature been eradicated in the latest compiler version? And what is the latest compiler version exactly (I'm currently back on 3.50) ? tia, O[-< -- |Oisin Hurley, | email: oh@iona.ie tel: +353-1-6686522 | |Iona Technologies + ftp: ftp.iona.ie fax: +353-1-6686573 | |8-34 Percy Place | free: 1-800-orbix4u (US only)| |Dublin 4, Ireland. | www: http://www.iona.ie/ |
Re: Bug in CC exception handling?
Author: Brad Ahlf
Date: Fri, 17 Nov 1995 21:04
Date: Fri, 17 Nov 1995 21:04
2 lines
745 bytes
745 bytes
Try WWW http://support.mayfield.hp.com/ Browse and Search patches. Look for C++ or for PHSS_6204 and browse the patch description info.
Re: Bug in CC exception handling?
Author: Russ W Soukoreff
Date: Thu, 23 Nov 1995 02:27
Date: Thu, 23 Nov 1995 02:27
181 lines
7185 bytes
7185 bytes
In article <489r8v$dri@news.Ieunet.ie> ohurley@iona.ie (Oisin Hurley) writes:
> eshayne@ibm.net (Ethan Shayne) writes:
>
> >I'm told by the HP people that there are actually a few separate
> >exception handling bugs which all show the same basic symptoms (i.e.
> >objects being destroyed twice). Many have been fixed and these fixes
> >are included in the latest patches which are already available.
>
> Can any HP people here drop a few pointers to the location of a description
> of these bugs plus associated patches? Has the old no +eh with +Z feature
> been eradicated in the latest compiler version? And what is the latest
> compiler version exactly (I'm currently back on 3.50) ?
I'm not HP, but I struggle enough with the stuff to be able to answer some
of your questions.
First, here is where I go to do my HPUX Patch Browsing and Downloading:
http://us.external.hp.com/slx/html/patches.html Fri Oct 13 11:02:31 1995
As far as C++ goes, I have found that version 3.72 is the most stable with
respect to exception handling and templates. The problems we've seen with
3.50 and 3.56 are too many to list, but I've include snippets of HP's bug
fixes from the 3.72 patch concerning "eh".
Patch Name: PHSS_5734
Patch Description: s700_800 9.X cumulative ld(1) and dld.sl(5) patch
Hardware Platforms - OS Releases: s700: 9.01 9.03 9.05 9.07 & s800: 9.00 9.04
This patch is needed by C++ customers who install patch
PHSS_5731, which allows C++ code in a shared library to
throw an exception. This patch replaces all previous
linker patches. ...
Supersedes:
PHSS_1782 PHSS_1783 PHSS_2187 PHSS_2188 PHSS_2534 PHSS_2535
PHSS_3011 PHSS_3012 PHSS_3068 PHSS_3069 PHSS_3536 PHSS_3537
PHSS_3598 PHSS_3812 PHSS_4366 PHSS_4411 PHSS_4644 PHSS_4716
PHSS_5083 PHSS_5290 PHSS_5564
Patch Name: PHSS_6204
======================
Patch Description: s700_800 9.X HP C++ patch A.03.72 to fix numerous defects
Creation Date: 95/10/24
Post Date: 95/11/07
Products:
The following symptoms correspond to the descriptions in
the defect descriptions field for patch PHSS_6204:
11. Can't rethrow an exception from within a shared library
30. Potential runtime error when calling derived destructor
explicitly
31. Explicit call to destructor results in compiler core
dump
32. Temporary destructed improperly, resulting in eh code to
core dump
49. Destructor without matching constructor when using +eh
on nested call
57. Template inline routine lost when -g/+eh is used, ld
unsat
58. Error 7103 with +eh and inline function, +T 1588, 1549
PHSS_5731:
The following symptoms correspond to the descriptions in
the defect descriptions field for patch PHSS_5731:
8. Error 3058 with +d with +eh in skiptypedefs
14. Runtime Internal Error: Index out of range on switch
with throw
19. Bad C is generated for inline function containing a
"throw" and a label
28. +eh core dumps on inline constructor
29. Runtime Internal Error: Index out of range with +eh,
inline destructor
30. Possible eh runtime errors on member initialization list
31. Destructor not getting called with +eh, arrays of class,
default parm
33. +Xehdtcount detects bad global reference in static ctor
34. Error 3058 with +eh and +T in cleanup_walk_statements
36. Error 7403, 5172 with +eh, inline of delete, +T gives
cc errors
37. Throw resulted in an abort due to illegal instruction,
branch to 0
38. Program aborts when compiling with +eh and initializing
with cast
43. Default constructor required in exception class
49. Error 3135 on global reference with +eh
50. Abort at runtime when +eh range errors
51. Program aborts when a throw is executed
11. A coredump will occur when using +eh in a shared library
in compiler mode. This will occur for any function that
has a try block that does not enclose the throw or the
call to the function that does a throw.
18. EH bug caused the code to compile unsuccessfuly.
29. A program generated an internal error.
30. Calling a derived destructor explicitly through a
reference caused a runtime error on throw.
31. The compiler core dumped when compiling a program with
+eh
44. Unsat when compiling with +eh __eh_Cfoo, first member
not defined.
55. When compiling a program with templates and typedefs and
using the options +eh and -g the compiler gave error
1034.
28. +eh core dumped on inline constructors that had a
return.
30. An eh runtime error sometimes occurred if an exception
was thrown during or after the construction of an object
in main().
31. Use of default constructors with default argument
expressions in the construction of an array of objects
caused bad eh code. Creating an array of objects
without explicit initialization corrupted the exception-
handling housekeeping information. As a result, not all
objects were destructed when an exception was thrown.
34. The elimination of compiler generated temporaries on the
eh side of the code mistakenly assumed that it was a
"non-symmetric temp".
38. eh destructor count incorrectly incremented when
initializing with cast
49. Internal Error 3135 sometimes occurred when compiling
with +eh when a global reference with an initializer was
encountered.
50. +eh problems with functions returning objects and copy
constructor
51. Objects or archive libraries compiled with +eh on 9.x
releases aborted when linked and run on 10.x. This only
occurred for functions with try/catch and only when the
throw is executed.
Supersedes:
PHSS_5089 PHSS_5090 PHSS_5731
Equivalent Patches: PHSS_6206: for HPUX 10.10
--- Russ Soukoreff, Software Consultant
XyTech Systems Inc. Alberta, Canada
Russ.Soukoreff@ipl.ca
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads