[LLVMbugs] [Bug 10718] New: ExecutionEngine construction not thread-safe

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 22 11:48:04 PDT 2011


           Summary: ExecutionEngine construction not thread-safe
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Target-Independent JIT
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, jediknil at belkadan.com

It is not safe to construct ExecutionEngines in multiple threads with different
LLVMContexts because they will call DynamicLibrary::LoadLibraryPermanently(...)
without any locking, and that boils down to a race condition between dlopen and

DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
                                                   std::string *errMsg) {
  void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
  if (handle == 0) {
    if (errMsg) *errMsg = dlerror();
    return DynamicLibrary();

Now, getPermanentLibrary has a lock in it which suggests that it should be
handling its own locking. Should the lock merely be shuffled above the dlopen?

Earlier verions of DynamicLibrary.h used to have a comment:
    /// NOTE: This function is not thread safe.
removed in r137791. Why?

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list