<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 - -Wdocumentation causes sporadic crash in clang::ASTContext::getRawCommentForDeclNoCacheImpl"
   href="https://bugs.llvm.org/show_bug.cgi?id=49707">49707</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wdocumentation causes sporadic crash in clang::ASTContext::getRawCommentForDeclNoCacheImpl
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sean@rogue-research.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We have a source file that reliably, but not always, causes clang 11.0.0 to
crash if and only if -Wdocumentation is used.

The .sh and .m file that the crash generates to *not* reproduce the issue, at
least not readily.  Perhaps with ASan or similar it might.  They are attached
regardless.

The only special thing about the source file (we think) is that it #includes
another source file.

We made a little shell script (runner.sh) that runs multiple clang processes. 
On some Macs it crashes quite easily, on others even running overnight it does
not.  We did not try other OSes.

We've also observed that after leaving it running for a little while, then
pressing Ctrl-C to cancel, clang will also crash, with seemingly the same
backtrace!

This crash also happens with AppleClang from Xcode 12 onwards, but not earlier.
 So it's probably a regression, though we did not regress it against open
source clang.

See the attached archive for the reproducer shell script, there's also a Read
Me inside.  Hopefully you can repro.

The backtrace from clang 11.0.0 [1] is:

0  clang                    0x000000010b4c4465
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  clang                    0x000000010b4c33f8 llvm::sys::RunSignalHandlers() +
248
2  clang                    0x000000010b4c3a30
llvm::sys::CleanupOnSignal(unsigned long) + 208
3  clang                    0x000000010b41505d CrashRecoverySignalHandler(int)
+ 189
4  libsystem_platform.dylib 0x00007fff700f25fd _sigtramp + 29
5  libsystem_platform.dylib 0x00007fdfb4858e00 _sigtramp + 18446743937419208736
6  clang                    0x000000010d511b11
clang::ASTContext::getRawCommentForDeclNoCacheImpl(clang::Decl const*,
clang::SourceLocation, std::__1::map<unsigned int, clang::RawComment*,
std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int
const, clang::RawComment*> > > const&) const + 513
7  clang                    0x000000010d51261a
clang::ASTContext::attachCommentsToJustParsedDecls(llvm::ArrayRef<clang::Decl*>,
clang::Preprocessor const*) + 378
8  clang                    0x000000010cead50a
clang::Sema::BuildDeclaratorGroup(llvm::MutableArrayRef<clang::Decl*>) + 986
9  clang                    0x000000010cfa08b8
clang::Sema::ActOnFinishObjCImplementation(clang::Decl*,
llvm::ArrayRef<clang::Decl*>) + 328
10 clang                    0x000000010cc6178c
clang::Parser::ParseObjCAtImplementationDeclaration(clang::SourceLocation,
clang::ParsedAttributes&) + 2828
11 clang                    0x000000010ccb44ac
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 540
12 clang                    0x000000010ccb3050
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
+ 1408
13 clang                    0x000000010cc00bad clang::ParseAST(clang::Sema&,
bool, bool) + 509
14 clang                    0x000000010bcde8da clang::FrontendAction::Execute()
+ 90
15 clang                    0x000000010bc66fa1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 2097
16 clang                    0x000000010bd4f50a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1962
17 clang                    0x000000010989f123 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 2131
18 clang                    0x000000010989d23c
ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 316
19 clang                    0x000000010baf2557 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__1::basic_string<char, std::__1::char_traits<char>,</span >
std::__1::allocator<char> >*, bool*) const::$_1>(long) + 23
20 clang                    0x000000010b414e12
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 226
21 clang                    0x000000010baf1915
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__1::basic_string<char, std::__1::char_traits<char>,</span >
std::__1::allocator<char> >*, bool*) const + 341
22 clang                    0x000000010bac186b
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const + 411
23 clang                    0x000000010bac1d8c
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&)
const + 124
24 clang                    0x000000010bada64c
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) +
396
25 clang                    0x000000010989cbf8 main + 10264


[1] specifically:
<a href="https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang+llvm-11.0.0-x86_64-apple-darwin.tar.xz">https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang+llvm-11.0.0-x86_64-apple-darwin.tar.xz</a></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>