Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile-time crash with virtual inheritance #410

Closed
ramosian-glider opened this issue Sep 1, 2015 · 2 comments
Closed

compile-time crash with virtual inheritance #410

ramosian-glider opened this issue Sep 1, 2015 · 2 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 3

LLVM r159521

% cat tsan-bug.cc 
struct AAA              {  virtual long aaa (); };
struct BBB: virtual AAA { unsigned long bbb; };
struct CCC: virtual AAA { };
struct DDD: CCC, BBB { DDD (); };
DDD::DDD()  { }


% clang -O2 -c -fthread-sanitizer tsan-bug.cc 
clang: /home/kcc/llvm/lib/VMCore/Constants.cpp:1366: static llvm::Constant *llvm::ConstantExpr::getCast(unsigned
int, llvm::Constant *, llvm::Type *): Assertion `CastInst::castIsValid(opc, C, Ty)
&& "Invalid constantexpr cast!"' failed.


The assertion happens here: 

bool ThreadSanitizer::instrumentLoadOrStore(Instruction *I) {                     


...
  if (IsWrite && isVtableAccess(I)) {                                             


    Value *StoredValue = cast<StoreInst>(I)->getValueOperand();                   


    IRB.CreateCall2(TsanVptrUpdate,                                               


                    IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),              


                    IRB.CreatePointerCast(StoredValue, IRB.getInt8PtrTy())); <<<<<<<<<<<<<<<<

The IR looks like this: 
  store i64 ptrtoint (i8** getelementptr inbounds ([9 x i8*]* @_ZTC3DDD8_3BBB, i64
0, i64 8) to i64), i64* %add.ptr.i, align 8, !tbaa !0

!0 = metadata !{metadata !"vtable pointer", metadata !1}


So, we have a store which is marked as "vtable pointer" but which is actually not a
pointer store.

Investigating. 

Reported by konstantin.s.serebryany on 2012-07-04 12:23:03

@ramosian-glider
Copy link
Member Author

fixed by LLVM r159736.

Reported by konstantin.s.serebryany on 2012-07-05 09:11:04

  • Status changed: Fixed

@ramosian-glider
Copy link
Member Author

Adding Project:ThreadSanitizer as part of GitHub migration.

Reported by glider@google.com on 2015-07-30 09:21:29

  • Labels added: ProjectThreadSanitizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant