[PATCH] D18847: Fix Registry::import() crash on mingw when loading a DLL plugin

Rudy Pons via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 04:36:06 PDT 2016


Ilod updated this revision to Diff 61353.
Ilod added a comment.

Updated to head. Removed the Cmake rule modification (because we need first to add some code in clang to really handle plugins on Windows).

To be more precise: the crash occurs on Windows clang built with MinGW if r260265 is applied and a plugin is used. r260265 has been reverted, and we need this patch before reapplying it to have support of Windows DLL plugins.


http://reviews.llvm.org/D18847

Files:
  include/llvm/Support/Registry.h

Index: include/llvm/Support/Registry.h
===================================================================
--- include/llvm/Support/Registry.h
+++ include/llvm/Support/Registry.h
@@ -135,16 +135,20 @@
         // current Registry.
         typedef std::pair<const node *, const node *> Info;
         Info *I = static_cast<Info *>(Getter());
-        iterator begin(I->first);
-        iterator end(I->second);
-        for (++end; begin != end; ++begin) {
-          // This Node object needs to remain alive for the
-          // duration of the program.
-          add_node(new node(*begin));
+        // We need to check I->first != Head for mingw, which build DLLs
+        // sharing extern symbols when using LLVM_BUILD_SHARED, so we don't
+        // copy the Registry in itself.
+        if (I->first != nullptr && I->first != Head) {
+          iterator begin(I->first);
+          iterator end(I->second);
+          for (++end; begin != end; ++begin) {
+            // This Node object needs to remain alive for the
+            // duration of the program.
+            add_node(new node(*begin));
+          }
         }
       }
     }
-
     /// Retrieve the data to be passed across DLL boundaries when
     /// importing registries from another DLL on Windows.
     static void *exportRegistry() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18847.61353.patch
Type: text/x-patch
Size: 1342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160621/6b63b9cd/attachment.bin>


More information about the llvm-commits mailing list