Hi, I've been debugging my multithreaded application using OpenSSL for three consequtive days, which crashed after processing about 5-200 SSL transactions.
The reason turned out to be the default CRYPTO_thread_id() implementation which uses getpid() as a thread identifier. This used to work on non-NPTL linuxthreads but does not work on anything using Linux 2.6 and NPTL as in this combination getpid() returns the same value for all threads. I have solved the problem myself by supplying a custom callback using CRYPTO_set_id_callback which uses the pthread id, however this problem probably affects a lot of openssl users, who have applications that run flawlessly on Linux 2.4 and after upgrading to a newer distribution the application will crash randomly as the issue causes a heap corruption. A clean non-pthread depending solution would be to use gettid(2) when available, it returns the pid of the thread instead of the application. (gettid is equal to pid in a non-threaded application). The problem with gettid() that it is not available in the libc and one has to use crude hacks to be able to use it. The following C programs works for me: #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <linux/unistd.h> #include <errno.h> _syscall0(pid_t,gettid) pid_t gettid(void); int main() { printf("%d\n", gettid()); } That code already contains a couple of #ifdefs anyway. The problem with the current situation is that everything _seems_ to work well, but whenever load hits the application it crashes and it is not easy to debug especially when one is looking for an error in his own code :) I would have opened a bug ticket but I have not found an obvious bug tracking system, so I decided to send it to openssl-dev in the hope that this is the right list. Please enlighten me if I am mistaken. -- Bazsi ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]