Skip to content

Instantly share code, notes, and snippets.

@dcci
Created December 22, 2015 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcci/efaea9678788d74769a4 to your computer and use it in GitHub Desktop.
Save dcci/efaea9678788d74769a4 to your computer and use it in GitHub Desktop.
dlopen() deadlock
#include <assert.h>
#include <link.h>
#include <dlfcn.h>
#include <stdio.h>
#include <pthread.h>
static int
callback(struct dl_phdr_info *info, size_t size, void *data)
{
void *handle;
handle = dlopen("/usr/lib/libpthread.so", RTLD_LAZY | RTLD_NOLOAD);
//dlsym(handle, ".swift2_protocol_conformances_start");
dlclose(handle);
return (0);
}
void
call_me_maybe(void *args) {
dl_iterate_phdr(callback, 0);
}
int
main(int argc, char *argv[])
{
pthread_t thread1;
pthread_create(&thread1, NULL, (void *) &call_me_maybe, NULL);
pthread_join(thread1, NULL);
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment