<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62592>62592</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            AddressSanitizer: use-after-poison when calling clang::CompilerInstance::createPreprocessor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jerry-tom
      </td>
    </tr>
</table>

<pre>
    we are experiencing a  AddressSanitizer: use-after-poison error w/ stack trace:
```
==83195==ERROR: AddressSanitizer: use-after-poison on address 0x000106201590 at pc 0x000100e58f34 bp 0x00016eff9bf0 sp 0x00016eff9be8
READ of size 8 at 0x000106201590 thread T0
    #0 0x100e58f30 in clang::IdentifierInfo::isOutOfDate() const IdentifierTable.h:415
    #1 0x100e58890 in clang::Preprocessor::MacroState::getModuleInfo(clang::Preprocessor&, clang::IdentifierInfo const*) const Preprocessor.h:830
    #2 0x10147fb5c in clang::Preprocessor::appendMacroDirective(clang::IdentifierInfo*, clang::MacroDirective*)+0xf4 (bkcheck_front:arm64+0x10067bb5c) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #3 0x101481b34 in clang::Preprocessor::RegisterBuiltinMacros()+0x64 (bkcheck_front:arm64+0x10067db34) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #4 0x10149beac in clang::Preprocessor::Preprocessor(std::__1::shared_ptr<clang::PreprocessorOptions>, clang::DiagnosticsEngine&, clang::LangOptions&, clang::SourceManager&, clang::HeaderSearch&, clang::ModuleLoader&, clang::IdentifierInfoLookup*, bool, clang::TranslationUnitKind)+0x534 (bkcheck_front:arm64+0x100697eac) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #5 0x101d589b0 in clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind)+0x160 (bkcheck_front:arm64+0x100f549b0) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #6 0x100e0f1a4 in PreProcess::Init() preprocess.cpp:416
    #7 0x100e0ec10 in PreProcess::PreProcess() preprocess.cpp:39
    #8 0x100e0f5a4 in PreProcess::PreProcess() preprocess.cpp:38
    #9 0x100eae7e4 in CheckFront::CheckFront() checkfront.cpp:7
    #10 0x100eae89c in CheckFront::CheckFront() checkfront.cpp:6
    #11 0x100e09430 in main bkcheck_front.cpp:116
    #12 0x18845bf24  (<unknown module>)

0x000106201590 is located 144 bytes inside of 4096-byte region [0x000106201500,0x000106202500)
allocated by thread T0 here:
 #0 0x10318b5cc in wrap_posix_memalign+0xa4 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x435cc) (BuildId: f0a7ac5c49bc3abc851181b6f92b308a32000000200000000100000000000b00)
    #1 0x18876ea18 in operator new(unsigned long, std::align_val_t)+0x38 (libc++abi.dylib:arm64e+0x17a18) (BuildId: fa1e66a848dd3435a00e4fcd9bf5de6932000000200000000100000000030d00)
    #2 0x100e5a7a0 in llvm::MallocAllocator::Allocate(unsigned long, unsigned long) AllocatorBase.h:86
    #3 0x100e5af68 in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::StartNewSlab() Allocator.h:339
    #4 0x100e5a154 in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::Allocate(unsigned long, llvm::Align) Allocator.h:195
    #5 0x1014a2778 in std::__1::pair<llvm::StringMapIterator<clang::IdentifierInfo*>, bool> llvm::StringMap<clang::IdentifierInfo*, llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>>::try_emplace<std::nullptr_t>(llvm::StringRef, std::nullptr_t&&)+0x78 (bkcheck_front:arm64+0x10069e778) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #6 0x1014a25c8 in clang::IdentifierTable::get(llvm::StringRef)+0x28 (bkcheck_front:arm64+0x10069e5c8) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #7 0x10149bd40 in clang::Preprocessor::Preprocessor(std::__1::shared_ptr<clang::PreprocessorOptions>, clang::DiagnosticsEngine&, clang::LangOptions&, clang::SourceManager&, clang::HeaderSearch&, clang::ModuleLoader&, clang::IdentifierInfoLookup*, bool, clang::TranslationUnitKind)+0x3c8 (bkcheck_front:arm64+0x100697d40) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #8 0x101d589b0 in clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind)+0x160 (bkcheck_front:arm64+0x100f549b0) (BuildId: 36c9bb3c2a7e30c49ec25b82b5646e6a32000000200000000100000000000d00)
    #9 0x100e0f1a4 in PreProcess::Init() preprocess.cpp:416
    #10 0x100e0ec10 in PreProcess::PreProcess() preprocess.cpp:39
    #11 0x100e0f5a4 in PreProcess::PreProcess() preprocess.cpp:38
    #12 0x100eae7e4 in CheckFront::CheckFront() checkfront.cpp:7
    #13 0x100eae89c in CheckFront::CheckFront() checkfront.cpp:6
    #14 0x100e09430 in main bkcheck_front.cpp:116
    #15 0x18845bf24  (<unknown module>)

SUMMARY: AddressSanitizer: use-after-poison IdentifierTable.h:415 in clang::IdentifierInfo::isOutOfDate() const
Shadow bytes around the buggy address:
  0x007020c60260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007020c60270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007020c60280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007020c60290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x007020c602a0: 00 00 00 04 f7 f7 f7 00 00 00 03 f7 f7 f7 00 00
=>0x007020c602b0: 00 01[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
 0x007020c602c0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
 0x007020c602d0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
 0x007020c602e0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
 0x007020c602f0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
 0x007020c60300: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
 Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
 Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope: f8
  Global redzone:          f9
  Global init order:       f6
 Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal: fe
  Left alloca redzone:     ca
  Right alloca redzone: cb
==83195==ABORTING
``` 
the code :
```c++
 m_compilerInst.createDiagnostics(nullptr, false);
 m_compilerInst.getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
    clang::TargetInfo* pTargetInfo = clang::TargetInfo::CreateTargetInfo(m_compilerInst.getDiagnostics(), m_compilerInst.getInvocation().TargetOpts);
 m_compilerInst.setTarget(pTargetInfo);
 m_compilerInst.createFileManager();
 m_compilerInst.createSourceManager(m_compilerInst.getFileManager());
 m_compilerInst.createPreprocessor(clang::TU_Complete);
 m_compilerInst.getDiagnosticClient().BeginSourceFile(m_compilerInst.getLangOpts(), &m_compilerInst.getPreprocessor());
``` 

llvm: 16.0.3
OS: Darwin Kernel Version 22.4.0
Compiler: clang version 14.0.3
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWtty46jWfhrlhmoXAh0vcuHYnZnUdE-6ksxf9V-5EFqSmcigApzDPP0u0MHnJDvb3Td7u1SxhR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