This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/19448] New: deadlock in dlopen when ctor calls dlopen in another thread


https://sourceware.org/bugzilla/show_bug.cgi?id=19448

            Bug ID: 19448
           Summary: deadlock in dlopen when ctor calls dlopen in another
                    thread
           Product: glibc
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: nszabolcs at gmail dot com
  Target Milestone: ---

an internal lock is held in dlopen while user code is executed (ctors).

this means user code can deadlock dlopen, observably breaking semantics
assuming thread creation is allowed in ctors.

thread creation is needed for the deadlock because GL(dl_load_lock) is
a recursive lock.

// main.c
#include <dlfcn.h>
int main()
{
        dlopen("mod.so", RTLD_NOW); // lock is held during ctors
}

// mod.c
#include <dlfcn.h>
#include <pthread.h>
static void *start(void *a)
{
        dlopen("xxx", RTLD_NOW); // lock in ctor in another thread
        return 0;
}
__attribute__((constructor)) static void foo(void)
{
        pthread_t td;
        pthread_create(&td, 0, start, 0);
        pthread_join(td, 0);  // main thread waits here
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]