[LLVMbugs] [Bug 9073] New: Create corrupted PCH if it includes libc++ <memory> file

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 27 09:53:12 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9073

           Summary: Create corrupted PCH if it includes libc++ <memory>
                    file
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=6060)
 --> (http://llvm.org/bugs/attachment.cgi?id=6060)
Test files

Precompiling a header that includes <memory> from libc++ in c++0x mode generate
a 'corrupted' file.

When trying to use the generated file, clang assert with the following error:

fatal error: malformed or corrupted PCH file: 'incorrect encoding of pack
expansion type'


The crash append when serializing this variadic template:


------------------------------- memory:3105
template<class _Tp>
template<class ..._Args>
shared_ptr<_Tp>
shared_ptr<_Tp>::make_shared(_Args&& ...__args)
{
    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
    typedef allocator<_CntrlBlk> _A2;
    typedef __allocator_destructor<_A2> _D2;
    _A2 __a2;
    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
    ::new(__hold2.get()) _CntrlBlk(__a2, std::__1::forward<_Args>(__args)...);
    shared_ptr<_Tp> __r;
    __r.__ptr_ = __hold2.get()->get();
    __r.__cntrl_ = __hold2.release();
    __r.__enable_weak_this(__r.__ptr_);
    return __r;
}
-------------------------------- memory:3121


To reproduce this issue, you can use the attached file:

clang version 2.9 (trunk 124376)

$ clang -x objective-c++-header -std=c++0x -stdlib=libc++ -c SharedPrefix.h -o
SharedPrefix.h.pth
$ clang -x objective-c++ -std=c++0x -stdlib=libc++ -include SharedPrefix.h -c
src.mm -o src.o
fatal error: malformed or corrupted PCH file: 'incorrect encoding of pack
expansion type'
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"),
function getCommonPtr, file
/Volumes/MacPro/Projects/OpenSource/llvm/tools/clang/lib/AST/../../include/clang/AST/Type.h,
line 388.

I also attach SharedPrefix.ii, the preprocessed version of SharedPrefix.h

-- 
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