<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - getASTRecordLayout called before that type's base classes are saved"
   href="https://bugs.llvm.org/show_bug.cgi?id=50054">50054</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>getASTRecordLayout called before that type's base classes are saved
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>emrekultursay@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24776" name="attach_24776" title="Full stack trace">attachment 24776</a> <a href="attachment.cgi?id=24776&action=edit" title="Full stack trace">[details]</a></span>
Full stack trace

This is a case where LLDB calls `Context.getASTRecordLayout(...)` for a class
BEFORE the `CXXRecordDecl::setBases()` for that same class.

As a result, `getASTRecordLayout()` computes and caches an layout without any
base classes, and subsequent calls use that cached, incorrect result. 

This causes a segfault in LLDB due to downstream accesses using FieldNo values
that do not exist in ASTRecordLayout.

I can only reproduce this by attaching to a binary that a customer provided,
and I cannot share that publicly here. However, I hope maybe some LLDB experts
here might be able to guide/help by looking at the stack trace here.

* Topmost frame: Computes and saves the ASTRecordLayout for the problematic
class without any base class information.
* Frame with asterisk(*): Has not processed/saved the base classes for that
same class yet.


<span class="quote">>        clang::ASTContext::getASTRecordLayout Line 3339 </span >
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        `anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes
Line 203   
        `anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap Line 179    
        clang::ASTContext::getASTRecordLayout Line 3377 
        clang::ASTContext::getTypeInfoImpl Line 2258    
        clang::ASTContext::getTypeInfo Line 1879        
        clang::ASTContext::getTypeInfo Line 2116        
        clang::ASTContext::getTypeSize Line 2122        
        lldb_private::TypeSystemClang::GetBitSize Line 4588     
        lldb_private::CompilerType::GetBitSize Line 484 
        lldb_private::CompilerType::GetByteSize Line 490        
        DWARFASTParserClang::ParseSingleMember Line 2680        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseChildMembers Line 2888        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParsePointerToMemberType Line 1362 
        DWARFASTParserClang::ParseTypeFromDWARF Line 530        
        ...
        DWARFASTParserClang::ParseChildParameters Line 3014     
        DWARFASTParserClang::ParseSubroutine Line 942   
        DWARFASTParserClang::ParseTypeFromDWARF Line 522        
        ...
        DWARFASTParserClang::CompleteRecordType Line 2003       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseSingleMember Line 2562        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParsePointerToMemberType Line 1362 
        DWARFASTParserClang::ParseTypeFromDWARF Line 530        
        ...
        DWARFASTParserClang::ParseChildParameters Line 3014     
        DWARFASTParserClang::ParseSubroutine Line 942   
        DWARFASTParserClang::ParseTypeFromDWARF Line 522        
        ...
        DWARFASTParserClang::CompleteRecordType Line 2003       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseSingleMember Line 2562        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParsePointerToMemberType Line 1362 
        DWARFASTParserClang::ParseTypeFromDWARF Line 530        
        ...
        DWARFASTParserClang::ParseChildParameters Line 3014     
        DWARFASTParserClang::ParseSubroutine Line 942   
        DWARFASTParserClang::ParseTypeFromDWARF Line 522        
        ...
        DWARFASTParserClang::CompleteRecordType Line 2003       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseSingleMember Line 2562        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParsePointerToMemberType Line 1362 
        DWARFASTParserClang::ParseTypeFromDWARF Line 530        
        ...
        DWARFASTParserClang::ParseChildParameters Line 3014     
        DWARFASTParserClang::ParseSubroutine Line 942   
        DWARFASTParserClang::ParseTypeFromDWARF Line 522        
        ...
        DWARFASTParserClang::CompleteRecordType Line 2003       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseSingleMember Line 2562        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseChildMembers Line 2888        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseChildMembers Line 2888        
*       DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseSingleMember Line 2562        
        DWARFASTParserClang::ParseChildMembers Line 2801        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParsePointerToMemberType Line 1362 
        DWARFASTParserClang::ParseTypeFromDWARF Line 530        
        ...
        DWARFASTParserClang::ParseChildParameters Line 3014     
        DWARFASTParserClang::ParseSubroutine Line 942   
        DWARFASTParserClang::ParseTypeFromDWARF L
        ...
        DWARFASTParserClang::CompleteRecordType Line 2003       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        ...
        DWARFASTParserClang::ParseChildMembers Line 2888        
        DWARFASTParserClang::CompleteRecordType Line 2002       
        DWARFASTParserClang::CompleteTypeFromDWARF Line 2126    
        SymbolFileDWARF::CompleteType Line 1484 
        lldb_private::TypeSystemClang::CompleteTagDecl Line 9100        
        GetCompleteQualType Line 2607   
        lldb_private::TypeSystemClang::GetNumChildren Line 5166 
        lldb_private::TypeSystemClang::GetNumChildren Line 5281 
        lldb_private::ValueObjectDynamicValue::CalculateNumChildren Line 96     
        lldb_private::ValueObject::GetNumChildren Line 561      
        lldb::SBValue::GetNumChildren Line 993  
        lldb::SBValue::GetNumChildren Line 982  
        [External Code] 


Full stack trace is attached.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>