This is an archive of the discontinued LLVM Phabricator instance.

Fix Registry::import() crash on mingw when loading a DLL plugin
Needs ReviewPublic

Authored by Ilod on Apr 6 2016, 4:31 PM.

Details

Summary

Fix support for importing and exporting Registry objects on Windows

On Windows, most compilers will produce a DLL with their own global Tail and Head variables, so we copy these variables returned from an exported function of the DLLs into the consumer Registry, but some (such as MinGW) shares it with the consumer (same as on other platforms).

Add a check before the copy to skip it if we detect the Head returned is the same as the consumer one, avoiding to copy it into itself, which is an infinite copy.
Also add null-check to avoid crash when exporting a DLL with no plugin registered.

Edit CMake rules to allow compiling example plugins on Windows.

Diff Detail

Event Timeline

Ilod updated this revision to Diff 52866.Apr 6 2016, 4:31 PM
Ilod retitled this revision from to Fix Registry::import() crash on mingw when loading a DLL plugin.
Ilod updated this object.
Ilod added reviewers: chapuni, ehsan, Bigcheese.
Ilod added a subscriber: llvm-commits.
Ilod updated this revision to Diff 61353.Jun 21 2016, 4:36 AM

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.