freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] OpenSSL support
- Date: Fri, 27 May 2005 20:08:32 +0200
Il giorno gio, 26-05-2005 alle 08:31 -0700, Peter Deacon ha scritto:
> On Thu, 26 May 2005, ZIGLIO, Frediano, VF-IT wrote:
>
> >> I think the problem might be with the global data loaded when openssl
> >> starts up. You can use ERR_free_strings and EVP_cleanup to
> >> axe the global
> >> structures at shutdown.
>
> > Nice shoot!
> > However this solution is good for an application but not for a
> > library... calling ERR_free_strings and/or EVP_cleanup while another
> > library can use openssl is not that good. strings and evp are global so
> > every library that use openssl in your application will not see
> > error/digest/cipher registered... I'm trying to patch openssl to free
> > its data while unloading library using gcc (not very portable but there
> > seems no way to handle this portably)...
>
> >From what I understand of unix dynamic libraries _init() is called at
> library load time and _fini() is called when the library is unloaded. So
> you'd just need to include the global free code in _fini? I have no idea
> who all supports such things but I do know it works on linux, freebsd and
> solaris. The system keeps a reference count so that if the same library
> is loaded multiple times _fini is called only when the reference count
> reaches zero.
>
Well, gcc support a better way, __attribute__ ((destructor)) and
__attribute__ ((constructor)) (see also src/tds/net.c or gcc manuals).
It define _init and _fini and calls constructors/destructors
automatically. This is the better using gcc compiler (note that it do
not require a ld linker but you have to link with gcc command, not ld).
Many systems support _init/_fini as you spot however gcc define these
symbols so you have to compile with -nostartfiles in order to use them
in your program. HP-UX has some problems... early version has a bug and
do not support correctly _init/_fini so you have to use some linker
switch (see http://docs.hp.com/en/B2355-90655/ch06s04.html#fig-init).
Solaris instead seems to support _init/_fini (see
http://docs.sun.com/app/docs/doc/817-1984/6mhm7pl17?
a=view#chapter2-48195) however using Sun compiler how declare
initializers/deinitializers in code??
> > A note about GnuTLS and OpenSSL. Beside license I found that OpenSSL is
> > more mature, thread safe but huge and complex... every part (error, hash
> > and others) can be overridden and follow the flow is very difficult.
> > GnuTLS is cleaner however it do not support some cipher suite (it do not
> > support any cipher I need for FreeTDS...). Using OpenSSL as a system
> > library (linked to many application/libraries) seems not that fine (it
> > contains leaks and global states which every application/library should
> > pay attention).
>
> I like OpenSSL :) Aside from the global data... The library maintains a
> session cache for quick reconnect of prioir ssl sessions which might be
> mistaken for a leak if your doing some sort of runtime checking? I don't
> have any experience with valgrind so I'll shutup now.
>
It's very easy to use valgrind. Just pass some parameter, executable and
it will tell (at end of program) which memory has not been freed (and
many more informations).
freddy77
-
[freetds] OpenSSL support,
ZIGLIO, Frediano, VF-IT, 05/25/2005
- Re: [freetds] OpenSSL support, Peter Deacon, 05/25/2005
- <Possible follow-up(s)>
-
RE: [freetds] OpenSSL support,
ZIGLIO, Frediano, VF-IT, 05/26/2005
-
RE: [freetds] OpenSSL support,
Peter Deacon, 05/26/2005
- RE: [freetds] OpenSSL support, Frediano Ziglio, 05/27/2005
-
RE: [freetds] OpenSSL support,
Peter Deacon, 05/26/2005
Archive powered by MHonArc 2.6.24.