<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Preprocessor leaks MacroInfo when completing macros"
   href="http://llvm.org/bugs/show_bug.cgi?id=19688">19688</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Preprocessor leaks MacroInfo when completing macros
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Repro:

 DYLD_LIBRARY_PATH=lib ./bin/c-index-test
-code-completion-at=../llvm-svn/tools/clang/test/Index/complete-preprocessor.m:9:8
../llvm-svn/tools/clang/test/Index/complete-preprocessor.m

with asan.

This allocates 3 MacroArgs objects, but frees only 2. This is the stack that
allocates the MacroArgs that aren't free'd:

    frame #1: 0x000000010031546b
libclang.3.5.dylib`clang::MacroArgs::create(clang::MacroInfo const*,
llvm::ArrayRef<clang::Token>, bool, clang::Preprocessor&) + 251
    frame #2: 0x0000000100343d34
libclang.3.5.dylib`clang::Preprocessor::ReadFunctionLikeMacroArgs(clang::Token&,
clang::MacroInfo*, clang::SourceLocation&) + 5956
    frame #3: 0x000000010033fdcd
libclang.3.5.dylib`clang::Preprocessor::HandleMacroExpandedIdentifier(clang::Token&,
clang::MacroDirective*) + 173
    frame #4: 0x00000001003577a2
libclang.3.5.dylib`clang::Preprocessor::HandleIdentifier(clang::Token&) + 1186
    frame #5: 0x0000000100307819
libclang.3.5.dylib`clang::Lexer::LexIdentifier(clang::Token&, char const*) +
265
    frame #6: 0x000000010030e8fc
libclang.3.5.dylib`clang::Lexer::LexTokenInternal(clang::Token&, bool) + 8476
    frame #7: 0x000000010030b711
libclang.3.5.dylib`clang::Lexer::Lex(clang::Token&) + 113
    frame #8: 0x00000001003578b4
libclang.3.5.dylib`clang::Preprocessor::Lex(clang::Token&) + 68
    frame #9: 0x00000001008a2898
libclang.3.5.dylib`clang::ParseAST(clang::Sema&, bool, bool) + 200
    frame #10: 0x00000001002c5757
libclang.3.5.dylib`clang::FrontendAction::Execute() + 71
    frame #11: 0x0000000100290b65
libclang.3.5.dylib`clang::ASTUnit::CodeComplete(llvm::StringRef, unsigned int,
unsigned int, llvm::ArrayRef<std::__1::pair<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >, llvm::MemoryBuffer
const*> >, bool, bool, bool, clang::CodeCompleteConsumer&,
clang::DiagnosticsEngine&, clang::LangOptions&, clang::SourceManager&,
clang::FileManager&, llvm::SmallVectorImpl<clang::StoredDiagnostic>&,
llvm::SmallVectorImpl<llvm::MemoryBuffer const*>&) + 3637
    frame #12: 0x0000000100045504 libclang.3.5.dylib`clang_codeCompleteAt_Impl
+ 1924
    frame #13: 0x0000000100767329
libclang.3.5.dylib`llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void
()>) + 233
    frame #14: 0x000000010076747c
libclang.3.5.dylib`RunSafelyOnThread_Dispatch(void*) + 28
    frame #15: 0x000000010079dc2d
libclang.3.5.dylib`ExecuteOnThread_Dispatch(void*) + 13
    frame #16: 0x00007fff90bcc899 libsystem_pthread.dylib`_pthread_body + 138
    frame #17: 0x00007fff90bcc72a libsystem_pthread.dylib`_pthread_start + 137</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>