Created
March 25, 2012 11:15
-
-
Save gaspard/2192960 to your computer and use it in GitHub Desktop.
Minimal main program for bug 24945
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <cstdio> | |
#include <cstring> // strerror | |
#include <errno.h> // errno | |
typedef void(*test_func)(bool); | |
int main() { | |
printf("Qt BUG related to dlclose\n=========================\n1. Program starting.\n"); | |
printf("2. Loading dynamic library 'mod.so' linked to Qt.\n"); | |
void *handle = dlopen("./mod.so", RTLD_NOW); | |
if (handle == NULL) { | |
printf("Library 'mod.so' not found (%s).\n", strerror(errno)); | |
return -1; | |
} | |
printf("3. Getting 'run_test' function.\n"); | |
test_func run_test = (test_func)dlsym(handle, "run_test"); | |
if (run_test == NULL) { | |
printf("Symbol not found.\n"); | |
return -1; | |
} | |
printf("4. Passing control to Qt.\n"); | |
/** The bug only happens if a QApplication is effectively started. | |
*/ | |
run_test(false); | |
printf("5. 'mod' returned.\n"); | |
printf("6. Calling dlclose.\n"); | |
/** This is where the bug appears. | |
*/ | |
dlclose(handle); | |
printf("7. Program end.\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment