Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion `(PtrWord & ~PointerBitMask) == 0 && "Pointer is not sufficiently aligned"' failed. #47651

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR48682
Status NEW
Importance P enhancement
Reported by Martin Liška (mliska@suse.cz)
Reported on 2021-01-07 02:54:05 -0800
Last modified on 2021-04-20 10:32:18 -0700
Version unspecified
Hardware PC Linux
CC bartde@microsoft.com, doko@ubuntu.com, klimek@google.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, sguelton@redhat.com, sylvestre@debian.org, tstellar@redhat.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Fails in clang_delta (part of C-Reduce and C-Vise) with LLVM12 only on armv7l:

Reproducer:

$ cat wxe_funcs.ii
static __typeof() a     __attribute__((__weakref__("pthread_mutex_destroy")))

$ valgrind /usr/lib/arm-linux-gnueabihf/clang_delta --query-instances=replace-
function-def-with-decl wxe_funcs.ii

==48917== Memcheck, a memory error detector
==48917== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==48917== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==48917== Command: /usr/lib/arm-linux-gnueabihf/clang_delta --query-
instances=replace-function-def-with-decl wxe_funcs.ii
==48917==
clang_delta: /usr/lib/llvm-11/include/llvm/ADT/PointerIntPair.h:178: static
intptr_t llvm::PointerIntPairInfo<PointerT, IntBits,
PtrTraits>::updatePointer(intptr_t, PointerT) [with PointerT = clang::Stmt*;
unsigned int IntBits = 1; PtrTraits =
llvm::PointerLikeTypeTraits<clang::Stmt*>; intptr_t = int]: Assertion `(PtrWord
& ~PointerBitMask) == 0 && "Pointer is not sufficiently aligned"' failed.
==48917==
==48917== Process terminating with default action of signal 6 (SIGABRT)
==48917==    at 0xB442216: __libc_do_syscall (libc-do-syscall.S:47)
==48917==    by 0xB451427: __libc_signal_restore_set (internal-signals.h:104)
==48917==    by 0xB451427: raise (raise.c:47)
==48917==    by 0xB441D55: abort (abort.c:79)
==48917==    by 0xB44C647: __assert_fail_base (assert.c:92)
==48917==    by 0xB44C6D1: __assert_fail (assert.c:101)
==48917==    by 0x969EAF: llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> >::updatePointer(int, clang::Stmt*)
[clone .part.0] (PointerIntPair.h:178)
==48917==    by 0x972259: updatePointer (SmallVector.h:345)
==48917==    by 0x972259: setPointerAndInt (PointerIntPair.h:76)
==48917==    by 0x972259: PointerIntPair (PointerIntPair.h:54)
==48917==    by 0x972259:
clang::RecursiveASTVisitor<ReplaceFunctionDefWithDeclCollectionVisitor>::TraverseStmt(clang::Stmt*,
llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool,
llvm::PointerLikeTypeTraits<clang::Stmt*>,
llvm::PointerIntPairInfo<clang::Stmt*, 1u,
llvm::PointerLikeTypeTraits<clang::Stmt*> > > >*) (RecursiveASTVisitor.h:576)
==48917==    by 0x97F703: TraverseVarDecl (RecursiveASTVisitor.h:2106)
==48917==    by 0x97F703:
clang::RecursiveASTVisitor<ReplaceFunctionDefWithDeclCollectionVisitor>::TraverseVarDecl(clang::VarDecl*)
(RecursiveASTVisitor.h:2106)
==48917==    by 0x96B6EB:
clang::RecursiveASTVisitor<ReplaceFunctionDefWithDeclCollectionVisitor>::TraverseDeclContextHelper(clang::DeclContext*)
[clone .part.0] (RecursiveASTVisitor.h:1383)
==48917==    by 0x96F179: TraverseDeclContextHelper (RecursiveASTVisitor.h:1377)
==48917==    by 0x96F179: TraverseTranslationUnitDecl
(RecursiveASTVisitor.h:1484)
==48917==    by 0x96F179:
clang::RecursiveASTVisitor<ReplaceFunctionDefWithDeclCollectionVisitor>::TraverseDecl(clang::Decl*)
(DeclNodes.inc:595)
==48917==    by 0x96B661:
ReplaceFunctionDefWithDecl::HandleTranslationUnit(clang::ASTContext&)
(ReplaceFunctionDefWithDecl.cpp:71)
==48917==    by 0x4E58C47: clang::ParseAST(clang::Sema&, bool, bool)
(clang/lib/Parse/ParseAST.cpp:171)

Note that it works for LLVM10 and LLVM8.
Quuxplusone commented 3 years ago

I can't see this anymore with LLVM 12 rc3.

Quuxplusone commented 3 years ago
I'm hitting the same issue when trying to run include-what-you-use on clang 11.

Error running '/tmp/build/bin/include-what-you-use': include-what-you-use:
/usr/lib/llvm-11/include/llvm/ADT/PointerIntPair.h:179: static intptr_t
llvm::PointerIntPairInfo<clang::Stmt *, 1,
llvm::PointerLikeTypeTraits<clang::Stmt *>>::updatePointer(intptr_t, PointerT)
[PointerT = clang::Stmt *, IntBits = 1, PtrTraits =
llvm::PointerLikeTypeTraits<clang::Stmt *>]: Assertion `(PtrWord &
~PointerBitMask) == 0 && "Pointer is not sufficiently aligned"' failed.
Quuxplusone commented 3 years ago
Version info of my setup:

Ubuntu clang version 11.1.0-++20210405103834+1fdec59bffc1-
1~exp1~20210405084454.165
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin