[stunnel-users] stunnel-4.15 segfaulting and looping under FreeBSD-CURRENT

Michael Weiser michael at weiser.dinsnail.net
Fri May 26 07:29:11 CEST 2006


On Wed, May 17, 2006 at 06:01:37PM +0200, Michael Weiser wrote:

> > I'm now retrying with a freshly compiled openssl-0.9.8b to see if that has
> > anything to do with anything.
> The problem persists with openssl-0.9.8b:

> # gdb src/stunnel --core stunnel.core --batch -ex "thread apply all bt
> full" -ex "quit"
> Core was generated by `stunnel'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x280d07b5 in SSL_get_peer_certificate () from
> ../bin/openssl-0.9.8b/lib/libssl.so.0.9.8
> [New LWP 100077]

The problem is triggered by a change to src/client.c in stunnel-4.15.
client() now loops over calls to run_client() instead of doing it just
once. The first, successful (!) call to run_client() seems to leave the
ssl context in an undefined state which makes the following calls to
run_client() segfault in the forked child which in turn produces the
core file. My guess is, that it's not actually supposed to loop if the
call to run_client() is successful.

Reverting client.c to roughly 4.14 fixes the problem for me. A patch is
attached. Any insights and a more permanent fix would be highly
appreciated.

BTW: I configured stunnel with --with-threads=pthread. By default,
ucontext is detected, which is broken in stunnel-4.14 as well. After
finishing, 4.14 hangs in s_poll_wait waiting for -1 seconds on 0 fds
(!?). I can provide debugging log and gdb output if needed.
-- 
bye, Michael
-------------- next part --------------
--- src/client.c~	Thu May 25 12:09:43 2006
+++ src/client.c	Thu May 25 12:49:15 2006
@@ -106,10 +106,8 @@
     if(c->opt->option.remote && c->opt->option.program) {
             /* connect and exec options specified together */
             /* -> spawn a local program instead of stdio */
-        while((c->local_rfd.fd=c->local_wfd.fd=connect_local(c))>=0) {
-            run_client(c);
-            sleep(1); /* FIXME: not a good idea in ucontext threading */
-        }
+        c->local_rfd.fd=c->local_wfd.fd=connect_local(c);
+        run_client(c);
     } else
 #endif
     {


More information about the stunnel-users mailing list