[llvm-branch-commits] [cfe-branch] r119646 - in /cfe/branches/Apple/whitney/tools/libclang: CIndex.cpp CIndexer.h

Daniel Dunbar daniel at zuster.org
Wed Nov 17 18:37:23 PST 2010


Author: ddunbar
Date: Wed Nov 17 20:37:23 2010
New Revision: 119646

URL: http://llvm.org/viewvc/llvm-project?rev=119646&view=rev
Log:
Merge r119047:
--
Author: Ted Kremenek <kremenek at apple.com>
Date:   Sun Nov 14 17:47:35 2010 +0000

    "Fix" some unintentional fallout from converting
    the Stmt* visitation in CursorVisitor to be
    data-recursive.

    Since AnnotationTokensWorker explicitly calls
    CursorVisitor::VisitChildren(), it essentially
    transforms the data-recursive algorithm in
    CursorVisitor back into a non-data recursive one.
    This is particularly bad because the data-recursive
    algorithm uses more stack space per stack frame,
    which can cause us to blow the stack in some cases.

    "Fix" this by making the stack that AnnotationTokensWorker
    runs in really huge.  The real fix is to modify
    AnnotationTokensWorker not to do the explicit
    recursive call.

Modified:
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
    cfe/branches/Apple/whitney/tools/libclang/CIndexer.h

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=119646&r1=119645&r2=119646&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:37:23 2010
@@ -4269,8 +4269,14 @@
                          TU, RegionOfInterest);
 
   // Run the worker within a CrashRecoveryContext.
+  // FIXME: We use a ridiculous stack size here because the data-recursion
+  // algorithm uses a large stack frame than the non-data recursive version,
+  // and AnnotationTokensWorker currently transforms the data-recursion
+  // algorithm back into a traditional recursion by explicitly calling
+  // VisitChildren().  We will need to remove this explicit recursive call.
   llvm::CrashRecoveryContext CRC;
-  if (!RunSafely(CRC, runAnnotateTokensWorker, &W)) {
+  if (!RunSafely(CRC, runAnnotateTokensWorker, &W,
+                 GetSafetyThreadStackSize() * 2)) {
     fprintf(stderr, "libclang: crash detected while annotating tokens\n");
   }
 }
@@ -4570,8 +4576,11 @@
 namespace clang {
 
 bool RunSafely(llvm::CrashRecoveryContext &CRC,
-               void (*Fn)(void*), void *UserData) {
-  if (unsigned Size = GetSafetyThreadStackSize())
+               void (*Fn)(void*), void *UserData,
+               unsigned Size) {
+  if (!Size)
+    Size = GetSafetyThreadStackSize();
+  if (Size)
     return CRC.RunSafelyOnThread(Fn, UserData, Size);
   return CRC.RunSafely(Fn, UserData);
 }

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndexer.h?rev=119646&r1=119645&r2=119646&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndexer.h (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndexer.h Wed Nov 17 20:37:23 2010
@@ -76,7 +76,7 @@
   ///
   /// \return False if a crash was detected.
   bool RunSafely(llvm::CrashRecoveryContext &CRC,
-                 void (*Fn)(void*), void *UserData);
+                 void (*Fn)(void*), void *UserData, unsigned Size = 0);
 }
 
 #endif





More information about the llvm-branch-commits mailing list