[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

svn_config_t is not thread-safe

From: Joel Jirak <joel_at_jirak.us>
Date: Mon, 3 Sep 2012 07:46:11 -0400

When debugging the recent TSVN cert problem, I noticed that even
though I specified a ssl cert in my servers file, I would sometimes
get prompted to enter my certificate when repo-browsing. This would
never happen when doing a show-log, but only when doing a repo-browse,
and then only about half the time. Still, it happened frequently
enough to make it reproducible.

The repo browse functionality seems to be the most threaded of any
TSVN operation. When I've trapped my problem in the debugger, here's
a typical scenario, with the following three functions on the stack,
in different stages of execution:

    TortoiseProc.exe!SVN::List()

    TortoiseProc.exe!SVNReadProperties::Refresh()

    TortoiseProc.exe!SVN::GetRepositoryRootAndUUID()

The reason TSVN sometimes fails to read my servers file correctly is
that SVNConfig is a singleton, but the svn struct svn_config_t
(defined in config_impl.h) is not thread-safe for reading due to
svn_config_t::tmp_key. tmp_key is used to hold the key from the
config file you want (like a section name or an actual setting within
a section) during a read. The read is interruptible, however, so,
multiple readers stomp on each others' tmp_key values when
simultaneously reading from a single instance of svn_config_t. Here's
a patch with some trace statements that show the problem
(svn_config_t_trace.patch). I've got a trace statement in
svn_ra_neon__open, which will see an intermittent failure when calling
svn_config_find_group().

svn_ra_neon__open() calls
svn_config_find_group(), which calls
svn_config_enumerate2(), which calls
find_option(), which calls
apr_hash_get() with tmp_key. Unfortunately, this tmp_key can change
while the hash lookup is going on.

I would assume that svn_config_t is not thread-safe by design. Thus,
TSVN should be changed. However, here's a hack patch that shows how
to get rid up the shared state in tmp_key. This patch does fix my
problem.

For the record, in all my tests, I started TSVN with: tortoiseproc
/command:repobrowser /path:https://<hostname>/<path to repo>

I'll send a follow-up email with possible patches for TSVN.

Thanks.

Joel Jirak

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=3003152

To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].

Received on 2012-09-03 13:46:17 CEST

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.