Problem calling virtual functions from base class constructors
Basics
Technical
Logistics
Basics
Technical
Logistics
Description
Since at least 12.2 of SunStudio, running unit tests crashes in a test case that clones an AuthenticationStatement. The crash shows a stack trace that isn't possible, and the this pointer changes in the debugger across calls such that the compiler seems to be trashing the object in some way when it executes the call.
I've traced it to the use of virtual methods inside base class constructors, in this case SubjectStatementImpl calling setSubject, which calls a virtual releaseDOM method. Moving that down to the subclass constructor fixes the crash.
It should be possible to rework these clone operations as two stages, one to initialize an empty object via copy constructor, and then an internal _clone method that actually copies the content.
Environment
Solaris 10, both archs, compiler package version > 12.0
Since at least 12.2 of SunStudio, running unit tests crashes in a test case that clones an AuthenticationStatement. The crash shows a stack trace that isn't possible, and the this pointer changes in the debugger across calls such that the compiler seems to be trashing the object in some way when it executes the call.
I've traced it to the use of virtual methods inside base class constructors, in this case SubjectStatementImpl calling setSubject, which calls a virtual releaseDOM method. Moving that down to the subclass constructor fixes the crash.
It should be possible to rework these clone operations as two stages, one to initialize an empty object via copy constructor, and then an internal _clone method that actually copies the content.