RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-30 Thread David Schwartz
> > 3) You cannot link to the pthreads library and still use fork, and > David, you absolutely cannot link with pthreads and still use fork() > It doesn't work except in a few very simplistic scenarios. > -paul What you are saying just doesn't make any sense. I agree that it is difficult

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-30 Thread Paul Sheer
> So you had a bug in your code. So what? No bug - read this: http://www.unix.org/version2/whatsnew/threadspaper.ps : Registration of fork handlers (pthread_atfork( )). The fork handlers are routines that are to be executed in association with calls to the fork( ) function. There are three c

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Kyle Hamilton
Any argument which begins with "on Linux" or (generalized) "on [platform]" is automatically suspect, regardless of whether there is any currently-extant platform which violates the assumptions put forward. For an example of why this is a problem, remember the assumption on 32- bit platform

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread David Schwartz
> On FreeBSD/OpenBSD my program outright core dumped and I could not > figure out why for days and days. So you had a bug in your code. So what? > Now I have two separate builds - one built > with "-D_REENTRANT -DTHREADS ... -lpthread" and one without. > Only with Linux do you have the freedom o

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Kurt Roeckx
On Tue, Jan 29, 2008 at 10:22:16PM +0200, Paul Sheer wrote: > > > > > > I find it hard to believe that there exists a platform where: > > > > On FreeBSD/OpenBSD my program outright core dumped and I could not > figure out why for days and days. Now I have two separate builds - one built > with "-D

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Paul Sheer
> > > I find it hard to believe that there exists a platform where: > On FreeBSD/OpenBSD my program outright core dumped and I could not figure out why for days and days. Now I have two separate builds - one built with "-D_REENTRANT -DTHREADS ... -lpthread" and one without. Only with Linux do you

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread David Schwartz
> Further, on some systems you can't link with libpthread > if you intend to use fork(). I have two builds of my > software, one that does fork()ing and one that does > pthread_create()ing. So I am trying to avoid having to have two > installations of OpenSSL on every build platform. I find it h

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Leandro Santi
Paul Sheer, 2008-01-29: > "it's own data"?? - well this is exactly why I asked on this > list :-) I wanted to get a better I idea about what "it's own > data" actually means. I am growing toward a complete list > of "it's own data" that does not appear to have any chance > of races. > > The fact t

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Leandro Santi
Leandro Santi, 2008-01-29: > I won't argue with you about using the library in an > undocumented manner; but I *do* think it'd be interesting > to get some real quantitative data: we could use it as a > basis to discuss possible future library modifications, > more compatible with your requests. O

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Paul Sheer
> This behavior, by itself, does not necessary guarantee > that your OpenSSL library code won't race against itself, > won't corrupt its own data, or crash (hint: learn about > the MySQL case, search the archives). "it's own data"?? - well this is exactly why I asked on this list :-) I wanted to

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-29 Thread Leandro Santi
Paul Sheer, 2008-01-29: > Let's say you have 1600 clients. Let's say that you have 40 threads, and > each thread > handles 40 connections. Now let's say that each thread initializes it's own > SSL_CTX structure. > > The SSL_CTX structure contains most of the data required for SSL > functionality. >

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-28 Thread Paul Sheer
Let's say you have 1600 clients. Let's say that you have 40 threads, and each thread handles 40 connections. Now let's say that each thread initializes it's own SSL_CTX structure. The SSL_CTX structure contains most of the data required for SSL functionality. Because each SSL_CTX structure has one

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-28 Thread Kurt Roeckx
On Mon, Jan 28, 2008 at 02:22:09PM -0800, David Schwartz wrote: > > > errno is stored in Thread Local Storage (TLS). You can't link to the > > global errno anymore. > > For a single-threaded process, there is no distinction between thread-local > storage and a global variable. For a multi-thread

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-28 Thread David Schwartz
> errno is stored in Thread Local Storage (TLS). You can't link to the > global errno anymore. For a single-threaded process, there is no distinction between thread-local storage and a global variable. For a multi-threaded process, there is. The same code can have a different semantic meaning d

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-28 Thread Kurt Roeckx
On Mon, Jan 21, 2008 at 05:34:43PM -0800, David Schwartz wrote: > > - there is no difference between > > multithreaded and non-multithreaded _compilation_ (surely not for errno > > and malloc). > > Really? So 'errno' refers to a process global in both cases?! (Note that I > said the "definition",

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-28 Thread Leandro Santi
Tomas Mraz, 2008-01-24: > So IMO what Paul Sheer is doing - disabling all locking in OpenSSL given > that there won't be any static and/or global variables in the OpenSSL > code called is 100% safe thing if the threads do not share any data > manipulated within the OpenSSL library. As mentioned in

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-26 Thread Jeffrey Altman
Paul Sheer wrote: Locking with no contention is not "pretty expensive", it's darn near free. Oh? If this is true it changes things somewhat. But I must say that I believe that no-one has ever used OpenSSL with 10'000 concurrent SSL objects. So I'm not going to take the chance that t

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread David Schwartz
David Jacobson wrote: > I'm only familiar with Solaris. In that system the real stuff > in a mutex is a byte about 12 bytes into the lock structure. > On SPARC the mutex_lock function accesses it with an LDSTUB > instruction, which is a special atomic instruction that loads > the old value into

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread Tomas Mraz
On Thu, 2008-01-24 at 09:11 -0800, David Schwartz wrote: > > > Really? So 'errno' refers to a process global in both cases?! > > > (Note that I > > > said the "definition", not the implementation.) > > > Maybe we didn't understand each other - I don't say, that glibc without > > multithread suppo

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread dmj2718-09
I'm only familiar with Solaris. In that system the real stuff in a mutex is a byte about 12 bytes into the lock structure. On SPARC the mutex_lock function accesses it with an LDSTUB instruction, which is a special atomic instruction that loads the old value into a register, and stores 0xff in

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread Richard Salz
> > On systems with only one processor and nothing like hyperthreading. > > Did you miss the "with no contention" part? No. I didn't realize you meant it as 'no possible contention.' /r$ -- STSM, DataPower Chief Programmer WebSphere DataPower SOA Appliances http://www.ibm.com/software/

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread Paul Sheer
I'm replying to David's email off-list... -paul On Jan 24, 2008 8:44 PM, David Schwartz <[EMAIL PROTECTED]> wrote: > > > But I must say that I believe that no-one has ever used OpenSSL > > with 10'000 concurrent SSL objects. > > Umm, what?! We've last tested to almost 16,384. Our first test to 1

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread David Schwartz
> > Locking with no contention is not "pretty expensive", it's darn near > > free. > On systems with only one processor and nothing like hyperthreading. Did you miss the "with no contention" part? An uncontended lock costs about the same on an SMP system as on an MP system. AFAIK, hyperthreading

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread David Schwartz
> But I must say that I believe that no-one has ever used OpenSSL > with 10'000 concurrent SSL objects. Umm, what?! We've last tested to almost 16,384. Our first test to 10,000 was many years ago, on servers with Pentium processors and 128MB of RAM. We've tested on operating systems from Windows

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread Richard Salz
> Locking with no contention is not "pretty expensive", it's darn near free. On systems with only one processor and nothing like hyperthreading. /r$ -- STSM, DataPower Chief Programmer WebSphere DataPower SOA Appliances http://www.ibm.com/software/integration/datapower/ __

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread Paul Sheer
> > > So IMO what Paul Sheer is doing - disabling all locking in OpenSSL given > > that there won't be any static and/or global variables in the OpenSSL > > code called is 100% safe thing if the threads do not share any data > > manipulated within the OpenSSL library. > > But that's not what he's d

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL-possible bug???)

2008-01-24 Thread David Schwartz
> > Really? So 'errno' refers to a process global in both cases?! > > (Note that I > > said the "definition", not the implementation.) > Maybe we didn't understand each other - I don't say, that glibc without > multithread support and with it is the same. I say that linking single > threaded libr

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-24 Thread Paul Sheer
> So IMO what Paul Sheer is doing - disabling all locking in OpenSSL given > that there won't be any static and/or global variables in the OpenSSL > code called is 100% safe thing [>] if [<] the threads do not share any data > manipulated within the OpenSSL library. Quite a big "if" there!

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-24 Thread Tomas Mraz
On Mon, 2008-01-21 at 17:34 -0800, David Schwartz wrote: > > On Sun, 2008-01-20 at 11:59 -0800, David Schwartz wrote: > > > > Most definitely not. At a minimum, the definition of things > > > like 'errno' and > > > 'malloc' might be different between a multithreaded build and a > > > non-multithr

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Paul Sheer
> Removing all the problems you can find is simply not a reliable way to > develop software. You have to design the software such that there aren't > problems, then remove any that slipped through. You can't use testing as the > way to create the guarantee in the first place. Heh :-) I totally ag

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread David Schwartz
> Guaranteed to work? Who's doing the indemnification? The point of a guarantee is that it is much less likely to change on another machine or if a library is upgraded and compatability is claimed. Of course, things can still go wrong. When bugs are fixed in a library or a new version claims co

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Paul Sheer
> > How are you sure of this ? Did you manually remove the object code from > the library, or place an abort(); call at the points -DPURIFY is listed > to you can be sure that execution never gets there. > Actually, I am trying to create an application that has one context per thread, where each

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Richard Salz
> IMO, writing security software by doing something that is specifically not > documented or guaranteed to work and then trying to fix every problem it > creates (at least, that you can find) is completely insane. Guaranteed to work? Who's doing the indemnification? Security's all about trade-

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Paul Sheer
> > IMO, writing security software by doing something that is specifically not > documented or guaranteed to work and then trying to fix every problem it > creates (at least, that you can find) is completely insane. > Ok, I managed to "find" another problem: error setting/getting (eg. ERR_clear_er

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Darryl Miles
Paul Sheer wrote: Well my hybrid threaded app now seems to be stable - even under extreme loads. 2. Use my own RAND object (RAND_set_rand_method) so that OpenSSL does not try lock static globals. How are you sure of this ? Did you manually remove the object code

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread David Schwartz
> Am I doing anything completely insane here? IMO, writing security software by doing something that is specifically not documented or guaranteed to work and then trying to fix every problem it creates (at least, that you can find) is completely insane. DS

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-22 Thread Paul Sheer
Well my hybrid threaded app now seems to be stable - even under extreme loads. Here is what I did for others to refer: Comments *most* welcome. These steps allow me to link both builds of my program with the same non-threaded OpenSSL build. I.e. both the fork() and pthread_create() builds of my

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL -possible bug???)

2008-01-21 Thread David Schwartz
> On Sun, 2008-01-20 at 11:59 -0800, David Schwartz wrote: > > Most definitely not. At a minimum, the definition of things > > like 'errno' and > > 'malloc' might be different between a multithreaded build and a > > non-multithreaded build. There is no supported way to combine > > multithreaded >

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???)

2008-01-21 Thread Kurt Roeckx
On Mon, Jan 21, 2008 at 09:24:34AM +0100, Tomas Mraz wrote: > On Sun, 2008-01-20 at 11:59 -0800, David Schwartz wrote: > > > I should be able to create a multithreaded application using > > > a non-multithreaded openssl build provided that I have an ssl > > > context per thread. > > > > Most defin

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???)

2008-01-21 Thread Tomas Mraz
On Sun, 2008-01-20 at 11:59 -0800, David Schwartz wrote: > > I should be able to create a multithreaded application using > > a non-multithreaded openssl build provided that I have an ssl > > context per thread. > > Most definitely not. At a minimum, the definition of things like 'errno' and > 'ma

Re: Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???)

2008-01-21 Thread paulsheer
ginal Message- From: "David Schwartz" <[EMAIL PROTECTED]> Date: Sun, 20 Jan 2008 11:59:00 To: Subject: RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???) > I should be able to create a multithreaded application using > a non-multithreaded openss

RE: Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???)

2008-01-20 Thread David Schwartz
> I should be able to create a multithreaded application using > a non-multithreaded openssl build provided that I have an ssl > context per thread. Most definitely not. At a minimum, the definition of things like 'errno' and 'malloc' might be different between a multithreaded build and a non-mul

Static global - bug? (Re: Two valgrind warnings in OpenSSL - possible bug???)

2008-01-19 Thread paulsheer
> The reason he said he used his own pseudo > random number generator is > actually because of the PURIFY option > that he didn't turn on. Actually the reason I use my own random number generator is because the openssl generator is not thread safe in the following way: I should be able to create