Bugs item #2800519, was opened at 2009-06-03 15:55
Message generated for change (Settings changed) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2800519&group_id=125852
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: misc
Group: None
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: libssh2 library is not thread safe
Initial Comment:
By default, there is no "-D_REENTRANT" flag passed to the C preprocessor (nor any -mt (Sun Studio) or -pthreads (gcc) option to the C compiler).
Note: I'm using libssh2 on Solaris 9/10, using Sun Studio 12.
Referencing errno in many pieces of code makes the whole library not thread safe (libssh2_session_startup() for example). There are many EAGAIN errors that are now thrown internally (because of new non-blocking sockets in 1.1), but unfortunately, the errno value is not correctly accessed, leading to undefined behaviour. This can be "easily" reproduced using something like (compiled in a thread safe manner):
Th.1: set errno
Th.1: detach thread 2
Th.2: establish an SSH connection. libssh2_session_startup() will usually fail.
I've passed CPPFLAGS="-D_REENTRANT" to the configure script, and things seem now to be OK.
Miscellaneous defects of the "configure" script:
- Specifying LDFLAGS="-mt -pthreads" does not pass these options to the ld linker.
- Specifying --disable-debug still compiles with "-g".
----------------------------------------------------------------------
>Comment By: Daniel Stenberg (bagder)
Date: 2009-06-04 20:26
Message:
I've now committed a fix for this in the git repo. It'd be great if you
tried it.
The fix will be included in the June 5 and later snapshots from =>
http://libssh2.haxx.se/snapshots.html
----------------------------------------------------------------------
Comment By: Gaƫtan Buchetet (p82420)
Date: 2009-06-04 11:13
Message:
Hello,
Sorry, but I'm not really confident with configure.in, m4 macros and all
that stuff.
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Date: 2009-06-04 08:55
Message:
The configure script obviously needs to check for _REENTRANT. I'm confident
we can get some inspiration and code from here:
http://curl.haxx.se/lxr/source/m4/curl-reentrant.m4#L390
You able to provide a patch?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=2800519&group_id=125852
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-06-04