site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com $ DYLD_INSERT_LIBRARIES=/path/to/my.dylib /path/to/the/executable However, I'm unable to run it in gdb: $ gdb /path/to/the/executable (gdb) set environment DYLD_INSERT_LIBRARIES=/path/to/my.dylib (gdb) run When I do that, I always get the following: /bin/bash: /usr/bin/arch: Operation not supported /bin/bash: /usr/bin/arch: Unknown error: 0 Program exited with code 01. int main(int argc, char *argv[]) { while (1) ; return 0; } -Jeff #include <pthread.h> #include <unistd.h> static void *MyThread(void *arg) { sleep(10); return NULL; } Hi. I'm experiencing a strange problem with gdb. I'm testing a version of a dylib that has a long-running pthread created in the constructor. This can be simulated with the example code at the end. If I use DYLD_INSERT_LIBRARIES to load the dylib on the command line, it works fine: On the other hand, if I uncomment the pthread_join line, it works fine. In other words, if the pthread is done before the constructor returns, it works, but if the pthread is still running, it dies. The nature of the executable doesn't seem to matter, it can be as simple as this: Is there something I need to do in gdb to get this to work? Or am I doing something wrong in the dylib? Are pthreads not supported in constructors? static __attribute__((constructor)) int LoadMyStuff(void) { static int didLoad = 0; if (!didLoad) { didLoad = 1; pthread_t aThread; pthread_create(&aThread, NULL, MyThread, NULL); //pthread_join(aThread, NULL); } return 0; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com