benlangmuir wrote:

I see that this change has already been reverted by @ilya-biryukov , but FYI 
before this is re-applied: I am seeing crashes from this change if I attempt to 
bootstrap a build of clang with modules enabled on Darwin.  I haven't yet 
managed to minimize a test case, but compiling the following triggers the issue 
at least when using the current Darwin libc++ 

```
#  include <string_view>

template <class _CharT, class _Traits, class _Tp>
struct __can_be_converted_to_string_view
    : public _BoolConstant< is_convertible<const _Tp&, 
basic_string_view<_CharT, _Traits> >::value &&
                            !is_convertible<const _Tp&, const _CharT*>::value > 
{};

```

The crash is because we get a call to `loadDeferredAttribute ` with a  
`nullptr` decl. During the read of `basic_string_view` from the module we end 
up calling `readAttributes` with no decl.  Not sure what was supposed to happen 
here.

```
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS 
(code=1, address=0x1c)
  * frame #0: 0x00000001032c293c 
clang++`clang::Decl::isFromASTFile(this=0x0000000000000000) const at 
DeclBase.h:786:39
    frame #1: 0x00000001032c28ec 
clang++`clang::ASTReader::getOwningModuleFile(this=0x000000015102d800, 
D=0x0000000000000000) const at ASTReader.cpp:8016:11
    frame #2: 0x00000001034642f8 
clang++`clang::ASTReader::loadDeferredAttribute(this=0x000000015102d800, 
DA=0x0000600003cb01e0) at ASTReaderDecl.cpp:4517:19
    frame #3: 0x00000001032d35b4 
clang++`clang::ASTReader::finishPendingActions(this=0x000000015102d800) at 
ASTReader.cpp:10244:7
    frame #4: 0x00000001032db234 
clang++`clang::ASTReader::FinishedDeserializing(this=0x000000015102d800) at 
ASTReader.cpp:10799:5
    frame #5: 0x00000001033111bc 
clang++`clang::ExternalASTSource::Deserializing::~Deserializing(this=0x000000016fdeedf0)
 at ExternalASTSource.h:88:15
    frame #6: 0x000000010328fbec 
clang++`clang::ExternalASTSource::Deserializing::~Deserializing(this=0x000000016fdeedf0)
 at ExternalASTSource.h:87:22
    frame #7: 0x00000001032c5ddc 
clang++`clang::ASTReader::FindExternalVisibleDeclsByName(this=0x000000015102d800,
 DC=0x000000015157f240, Name=(Ptr = 5659675880), OriginalDC=0x000000015157f240) 
at ASTReader.cpp:8525:1
    frame #8: 0x0000000105794d78 
clang++`clang::DeclContext::lookupImpl(clang::DeclarationName, 
clang::DeclContext const*) const + 716
    frame #9: 0x0000000104e13738 clang++`LookupDirect(clang::Sema&, 
clang::LookupResult&, clang::DeclContext const*) + 108
```

https://github.com/llvm/llvm-project/pull/122726
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to