On Sat, Aug 11, 2012 at 03:07:40PM +0300, Damyan Ivanov wrote:
> Trying to run cvs via torsocks causes a segfault in libtorsocks.so:
> 
>  $ torsocks cvs up
>  zsh: segmentation fault  torsocks cvs up
> 
> The backtrace is:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7bd4694 in find_socks_request ()
>    from /usr/lib/torsocks/libtorsocks.so
> (gdb) bt
> #0  0x00007ffff7bd4694 in find_socks_request ()
>    from /usr/lib/torsocks/libtorsocks.so
> #1  0x00007ffff7bcfbeb in torsocks_close_guts ()
>    from /usr/lib/torsocks/libtorsocks.so
> #2  0x00007ffff7055be1 in ?? () from /lib/x86_64-linux-gnu/libbsd.so.0
> #3  0x00007ffff7055f3d in arc4random () from /lib/x86_64-linux-gnu/libbsd.so.0
> #4  0x0000555555567f30 in main ()
> 
> To reproduce try running:
> 
>  torsocks cvs -d :pserver:anonym...@anonscm.debian.org:/cvs/webwml checkout 
> webwml/english/doc

First, the problem does not appear when using CVS from Squeeze (that's
version 1:1.12.13-12+squeeze1). So it looks like it is triggered by a
change in the behaviour there, or some other change in the toolchain.

The segfault appears because at some point "requests" (defined at
socks.c:87) is not NULL, but no connections have been made yet.

This is strange, because it is defined to be NULL and so should be when
the library gets loaded. If I force it to NULL by modifying
torsocks_init(), then I have no segfaults, by CVS fails with the
following:

    cvs [checkout aborted]: internal error: testing support for unknown request?

The patch is the following:

--- a/src/torsocks.c
+++ b/src/torsocks.c
@@ -187,6 +187,7 @@ void torsocks_init(void)
         show_msg(MSGERR, "Fatal error: exiting\n");
         exit(1);
     }
+    requests = NULL;
 
     pthread_mutex_unlock(&torsocks_init_mutex);
 

This is a weird issue. Maybe we should ask CVS maintainers if they have
a clue…

Cheers,
-- 
Jérémy Bobbio                        .''`. 
jeremy.bob...@irq7.fr               : :   :             lu...@debian.org
                                    `. `'` 
                                      `-

Attachment: signature.asc
Description: Digital signature

Reply via email to