apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bert Huijben" <b...@qqmail.nl>
Subject [Patch] Fix for concurrent/race condition in apr_dir_make_recursive()
Date Thu, 16 Jan 2014 14:19:45 GMT
	Hi,

While debugging a Subversion buildbot error I found a race condition in
apr_dir_make_recursive().

If two new threads perform something like
$ mkdir -p some/deep/sub/dir
$ mkdir -p some/deep/sub/other
At the same time

And 'some' and/or 'deep' don't exist both threads will fail to create their
final directory part and then try to create the parent directories. If their
first attempt fails they try to create the parent directory, and then itself
again. But if the other thread was first, we get an EEXISTS error. This
error is ignored by the inner implementation, but the outer function
accidentally converts this to APR_SUCCESS even though the requested
directory isn't created.

[[
* file_io/win32/dir.c
  (dir_make_parent): When parent just got created, continue creating
children.
  (apr_dir_make_recursive): Only handle EEXIST of the requested directory as
success,
    not any ancestor.

Patch by: rhuijben
]]

At first glance it appears the same problem exists on other platforms (most
importantly the standard unix code) too.

Branko might already be looking at this patch as we discussed it on
#svn-dev.

It would be nice to have the patch (or something similar) applied in the
next apr 1.5.x release (and perhaps also on some older branches), as this
problem causes some very hard to diagnose errors in the Subversion test
suite.
We assumed that the function would succeed or return an error; not fail
without an error. So we were verifying and tweaking the code after calling
this function again and again.

	Bert

Mime
View raw message