[LLVMbugs] [Bug 9660] New: Polymorphic return types conflict with virtual base class → executable segfaults
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 8 11:16:41 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9660
Summary: Polymorphic return types conflict with virtual base
class → executable segfaults
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: ejtttje at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=6422)
--> (http://llvm.org/bugs/attachment.cgi?id=6422)
sample code
In the attached sample code, there is a 'Cloneable' interface to provide
'clone()'.
Another class 'Base' inherits virtually from Cloneable, providing a Base*
clone(), and a third class 'Derived' inherits from Base, providing its own
Derived* clone().
When Derived::clone() is called, the code generated by clang will crash, as
shown in this log from gdb running the attached sample code
(gdb) run
Starting program: /Users/ejt/test
Reading symbols for shared libraries ++. done
Base clone works!
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff70ec2990
0x00007fff70ec2990 in vtable for __cxxabiv1::__class_type_info ()
(gdb) bt
#0 0x00007fff70ec2990 in vtable for __cxxabiv1::__class_type_info ()
#1 0x00000001000016fb in main (argc=1, argv=0x7fff5fbff730) at test.cc:26
All of the elements described above are necessary to reproduce this bug.
Cloneable must provide the function prototype, Base must use virtual
inheritance, and Base must update the return type. If any one of these items
is removed, then the crash does not occur. Also, as noted in the above output,
Base::clone() can be called successfully, it is only the Derived::clone() which
crashes.
g++ and llvm-g++ will compile this code for successful execution.
This issue occurs identically with both the Apple clang (Apple clang version
2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)) as well as the latest svn
(revision 129132)
Thanks!
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list