Login | Register
My pages Projects Community openCollabNet

Discussions > issues > [Issue 200] New - pysvn.Client.root_url_from_path segfault in login callback

pysvn
Discussion topic

Back to topic list

[Issue 200] New - pysvn.Client.root_url_from_path segfault in login callback

Author mtoossi
Full name Mohammad Toossi
Date 2015-05-25 00:01:40 PDT
Message http://pysvn.tigris.​org/issues/show_bug.​cgi?id=200
                 Issue #|200
                 Summary|pysvn.Client​.root_url_from_path segfault in login call
                        |back
               Component|pysvn
                 Version|current
                Platform|Other
              OS/Version|Linux
                     URL|
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|extension
             Assigned to|barryscott
             Reported by|mtoossi






------- Additional comments from mtoossi at tigris dot org Mon May 25 00:00:58 -0700 2015 -------
pysvn.Client.root_url_from_path causes SIGSEGV if it needs to invoke callback_get_login

SAMPLE PROGRAM
===============
import pysvn
cl = pysvn.Client()
def _get_login(realm, username, may_save):
    return (True, 'user', 'password', False)
cl.callback_get_login = _get_login
# Assuming that no saved password is available
cl.root_url_from_pat​h('svn://localhost/t​est')

STACKTRACE
===========
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff68f564c in PythonAllowThreads::​allowThisThread() () from /path/to/venv/lib/py​thon2.7/site-
packages/pysvn/_pysvn_2_7.so
(gdb) bt
#0 0x00007ffff68f564c in PythonAllowThreads::​allowThisThread() () from /path/to/venv/lib/py​thon2.7/site-
packages/pysvn/_pysvn_2_7.so
#1 0x00007ffff68f5690 in PythonDisallowThread​s::PythonDisallowThr​eads(PythonAllowThre​ads*) () from
/path/to/venv/lib/py​thon2.7/site-package​s/pysvn/_pysvn_2_7.s​o
#2 0x00007ffff692dce5 in pysvn_context::contextGetLogin (this=0x9c4b50, _realm=..., _username=...,
_password=..., _may_save=@0x7fffffffceaf: true) at pysvn_callbacks.cpp:105
#3 0x00007ffff6983c70 in handlerSimplePrompt (cred=0x7fffffffcff0, baton=0x9c4b50, a_realm=0x7ffff1a5fc98 "
<svn://localhost:3690> f20d645d-0cff-46d5-a​06b-d9908866df32",
    a_username=0x7ffff7dfe360 “test”, a_may_save=1, pool=0x7ffff7ff2028) at pysvn_svnenv.cpp:249
#4 0x00007ffff5c629c2 in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_subr-1.​so.1
#5 0x00007ffff5c62c7c in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_subr-1.​so.1
#6 0x00007ffff5c3c258 in svn_auth_first_credentials () from /usr/lib/x86_64-linu​x-gnu/libsvn_subr-1.​so.1
#7 0x00007ffff3b179c8 in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#8 0x00007ffff3b17aba in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#9 0x00007ffff1e6e7b7 in _plug_get_simple () from /usr/lib/x86_64-linu​x-gnu/sasl2/libcramm​d5.so
#10 0x00007ffff1e6dc53 in ?? () from /usr/lib/x86_64-linu​x-gnu/sasl2/libcramm​d5.so
#11 0x00007ffff30ed5f0 in sasl_client_step () from /usr/lib/x86_64-linu​x-gnu/libsasl2.so.2
#12 0x00007ffff3b188c1 in svn_ra_svn.do_cyrus_auth () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#13 0x00007ffff3b11953 in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#14 0x00007ffff3b136c3 in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#15 0x00007ffff3b16b43 in ?? () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra_svn-​1.so.1
#16 0x00007ffff50c085a in svn_ra_open4 () from /usr/lib/x86_64-linu​x-gnu/libsvn_ra-1.so​.1
#17 0x00007ffff65ca5b0 in svn_client.open_ra_s​ession_internal () from /usr/lib/x86_64-linu​x-gnu/libsvn_client-​1.so.1
#18 0x00007ffff65ca62d in svn_client_open_ra_session2 () from /usr/lib/x86_64-linu​x-gnu/libsvn_client-​1.so.1
#19 0x00007ffff65d2388 in svn_client_get_repos_root () from /usr/lib/x86_64-linu​x-gnu/libsvn_client-​1.so.1
#20 0x00007ffff65a44b0 in svn_client_root_url_from_path () from /usr/lib/x86_64-linu​x-gnu/libsvn_client-​1.so.1
#21 0x00007ffff6936bef in pysvn_client::cmd_ro​ot_url_from_path(Py:​:Tuple const&, Py::Dict const&) () from
/path/to/venv/lib/py​thon2.7/site-package​s/pysvn/_pysvn_2_7.s​o
#22 0x00007ffff69397ef in Py::PythonExtension​<pysvn_client>:​:method_keyword_call​_handler(_object*, _object*,
_object*) ()
   from /path/to/venv/lib/py​thon2.7/site-package​s/pysvn/_pysvn_2_7.s​o
#23 0x000000000052c6d5 in PyEval_EvalFrameEx ()
#24 0x000000000055c594 in PyEval_EvalCodeEx ()
#25 0x00000000005b7392 in PyEval_EvalCode ()
#26 0x0000000000469663 in ?? ()
#27 0x00000000004699e3 in PyRun_FileExFlags ()
#28 0x0000000000469f1c in PyRun_SimpleFileExFlags ()
#29 0x000000000046ab81 in Py_Main ()
#30 0x00007ffff7818ec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fffffffdec8, init=<optimized
out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdeb8)
    at libc-start.c:287
#31 0x000000000057497e in _start ()

THE ISSUE
=========
In svn_client_root_url_from_path, variable m_context.m_permission is NULL.
PythonDisallowThread​s::PythonDisallowThr​eads then tries to dereference the NULL pointer inside callback.

POSSIBLE FIX
===========
The following change fixed it for me, but I'm quite unfamiliar with this code.

diff -ru a/pysvn-1.7.10/Sourc​e/pysvn_client.cpp b/pysvn-1.7.10/Sourc​e/pysvn_client.cpp
--- a/pysvn-1.7.10/Sourc​e/pysvn_client.cpp 2014-01-11 07:34:05.000000000 -0800
+++ b/pysvn-1.7.10/Sourc​e/pysvn_client.cpp 2015-05-24 23:38:07.806015812 -0700
@@ -721,6 +721,10 @@
     {
         std::string norm_path( svnNormalisedIfPath( path, pool ) );
 
+ checkThreadPermission();
+
+ PythonAllowThreads permission( m_context );
+
         svn_error_t *error = svn_client_root_url_from_path
             (
             &root_url,

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

[Issue 200] New - pysvn.Client.root_url_from_path segfault in login callback mtoossi Mohammad Toossi 2015-05-25 00:01:40 PDT
     [Issue 200] pysvn.Client.root_url_from_path segfault in login callback barryscott Barry Scott 2015-09-07 10:02:53 PDT
Messages per page: