You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Rall <dl...@collab.net> on 2005/10/28 00:03:19 UTC

Path canonicalization assertion failure triggered by add_dir_recursively()

I detected this problem while running 'make check-javahl'.  The
BasicTests.testBasicAddIgnores() test creates the following working
copy, and triggers this assertion failure.

$ ls -la /home/dlr/src/subversion/working_copies/basic_test1/dir
total 8
drwxrwxr-x  2 dlr dlr 4096 Oct 27 16:51 ./
drwxrwxr-x  5 dlr dlr 4096 Oct 27 16:20 ../
-rw-rw-r--  1 dlr dlr    0 Oct 27 16:20 foo.c
-rw-rw-r--  1 dlr dlr    0 Oct 27 16:20 foo.o

$ svn add /home/dlr/src/subversion/working_copies/basic_test1/dir
A         /home/dlr/src/subversion/working_copies/basic_test1/dir
svn: subversion/libsvn_subr/path.c:377: svn_path_basename: Assertion `is_canonical (path, len)' failed.
Aborted

The stack trace is as follows:

#0  0x00365402 in __kernel_vsyscall ()
#1  0x0085b1f8 in raise () from /lib/libc.so.6
#2  0x0085c948 in abort () from /lib/libc.so.6
#3  0x0085438e in __assert_fail () from /lib/libc.so.6
#4  0x0031c3b4 in svn_path_basename (path=0x954e870 ".", pool=0x954e820)
    at subversion/libsvn_subr/path.c:377
#5  0x0040f8d1 in svn_wc_is_adm_dir (name=0x954e870 ".", pool=0x954e820)
    at subversion/libsvn_wc/adm_files.c:60
#6  0x00ef1793 in add_dir_recursive (
    dirname=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir", adm_access=0x9540c28, force=0, no_ignore=0, ctx=0x9532e68, pool=0x95409d0)
    at subversion/libsvn_client/add.c:331
#7  0x00ef1a82 in add (
    path=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir",
    recursive=1, force=0, no_ignore=0, adm_access=0x9540c28, ctx=0x9532e68,
    pool=0x95409d0) at subversion/libsvn_client/add.c:413
#8  0x00ef1b9b in svn_client_add3 (
    path=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir",
    recursive=1, force=0, no_ignore=0, ctx=0x9532e68, pool=0x95409d0)
    at subversion/libsvn_client/add.c:448
#9  0x0804be42 in svn_cl__add (os=0x9532ab0, baton=0xbfb37818, pool=0x9532998)
    at subversion/clients/cmdline/add-cmd.c:65
#10 0x08052826 in main (argc=3, argv=0xbfb379c4)
    at subversion/clients/cmdline/main.c:1503

The error occurs because "." is passed to svn_wc_is_adm_dir(), which
eventually triggers the is_canonical() assertion failure in
svn_path_basename().  add_dir_recursive(), the caller of
svn_wc_is_adm_dir(), contains code which filters out empty, parent,
and "." paths, but that code isn't executed in time.

The attached patch corrects this misbehavior (I'll commit it for the
time being), but while looking through svn_io.h, I noticed that there
are some functions which declare similar filtering behavior
(e.g. svn_io_get_dirents2).  Would someone familiar with this code
please comment on whether one of these alternate functions would be
more appropriate?  Thanks!
-- 

Daniel Rall

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Daniel Rall <dl...@collab.net>.
On Fri, 28 Oct 2005, Marc Sherman wrote:

> Philip Martin wrote:
> >
> >Subeclipse can call svn_path_basename before calling
> >svn_wc_is_adm_dir, is there some reason that it's better for
> >Subversion to do it?  On the whole I tend to favour the existing
> >interface.
> 
> My understanding of that thread was that the Subclipse folks just wanted 
> the docstring updated to assert that the name parameter must be a 
> basename already.

Marc, looks like you're right -- Mark Phippard had already followed up
saying as much.
http://svn.haxx.se/dev/archive-2005-10/0994.shtml

Thanks!
-- 

Daniel Rall

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Marc Sherman <ms...@projectile.ca>.
Philip Martin wrote:
> 
> Subeclipse can call svn_path_basename before calling
> svn_wc_is_adm_dir, is there some reason that it's better for
> Subversion to do it?  On the whole I tend to favour the existing
> interface.

My understanding of that thread was that the Subclipse folks just wanted 
the docstring updated to assert that the name parameter must be a 
basename already.

- Marc


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Semantics of svn_wc_is_adm_dir(), and interaction with bindings

Posted by Philip Martin <ph...@codematters.co.uk>.
Daniel Rall <dl...@collab.net> writes:

> On Fri, 28 Oct 2005, Philip Martin wrote:
>
>> Subeclipse can call svn_path_basename before calling
>> svn_wc_is_adm_dir, is there some reason that it's better for
>> Subversion to do it?
>
> Well, Subclipse actually has no access to svn_path_basename()

Subeclipse must have some way to manipulate paths, a regexp replace
would do, it doesn't have to use svn_path_basename.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Semantics of svn_wc_is_adm_dir(), and interaction with bindings

Posted by Daniel Rall <dl...@collab.net>.
On Fri, 28 Oct 2005, Philip Martin wrote:

> Daniel Rall <dl...@finemaltcoding.com> writes:
> 
> > Turns out the call to svn_path_basename() from svn_wc_is_adm_dir() was
> > a local hack I had in my working copy which was requested by the
> > Subclipse folks (I didn't see any comments on the patch when I last
> > posted it to list, but could've missed them).  Any objections to me
> > committing both patches?  I do have some concern that the previously
> > super-thin svn_wc_is_adm_dir() routines becomes heavier because of
> > this change.  Thoughts?
> 
> Subeclipse can call svn_path_basename before calling
> svn_wc_is_adm_dir, is there some reason that it's better for
> Subversion to do it?

Well, Subclipse actually has no access to svn_path_basename(), and in
SVN 1.3 there is not even documentation indicating that this is
required.  What Subclipse can do is use java.io.File to acquire the
base name of the directory:
http://java.sun.com/j2se/1.3/docs/api/java/io/File.html#getName()

Alternately, the bindings could each perform svn_path_basename() (or
the language-specific equivalent).  I'm not particularly in favor of
the irregularity nor extra code involved in this approach.

> On the whole I tend to favour the existing interface.

This came up in the first place because svn_wc_is_adm_dir() was not
documented as to whether it acted on a path or single component of a
directory name.  Both Mark Phippard and myself individually ran into
this question while interacting with the new API.  I have subsequently
clarified the API's doc string in trunk.

> Obviously you need to update the header file as well.
> 
> > Index: subversion/libsvn_wc/adm_files.c
> > ===================================================================
> > --- subversion/libsvn_wc/adm_files.c	(revision 17065)
> > +++ subversion/libsvn_wc/adm_files.c	(working copy)
> > @@ -57,7 +57,7 @@
> >  svn_boolean_t
> >  svn_wc_is_adm_dir (const char *name, apr_pool_t *pool)
> 
> Use 'path' rather than 'name'.
> 
> >  {
> > -  (void)pool;  /* Silence compiler warnings about unused parameter. */
> > +  name = svn_path_basename (name, pool);
> >    return (0 == strcmp (name, adm_dir_name)
> >            || 0 == strcmp (name, default_adm_dir_name));
> >  }

Yeah, both these changes would be necessary, thanks Philip.  However,
with the documentation for the function fixed, I'm also ambivalent on
this change.  Seems like with as often as the function is called,
there are some moderate performance benefits to leaving it as-is.

Mark, do you think this is still necessary?
--

Daniel Rall

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Philip Martin <ph...@codematters.co.uk>.
Daniel Rall <dl...@finemaltcoding.com> writes:

> Turns out the call to svn_path_basename() from svn_wc_is_adm_dir() was
> a local hack I had in my working copy which was requested by the
> Subclipse folks (I didn't see any comments on the patch when I last
> posted it to list, but could've missed them).  Any objections to me
> committing both patches?  I do have some concern that the previously
> super-thin svn_wc_is_adm_dir() routines becomes heavier because of
> this change.  Thoughts?

Subeclipse can call svn_path_basename before calling
svn_wc_is_adm_dir, is there some reason that it's better for
Subversion to do it?  On the whole I tend to favour the existing
interface.

Obviously you need to update the header file as well.

> Index: subversion/libsvn_wc/adm_files.c
> ===================================================================
> --- subversion/libsvn_wc/adm_files.c	(revision 17065)
> +++ subversion/libsvn_wc/adm_files.c	(working copy)
> @@ -57,7 +57,7 @@
>  svn_boolean_t
>  svn_wc_is_adm_dir (const char *name, apr_pool_t *pool)

Use 'path' rather than 'name'.

>  {
> -  (void)pool;  /* Silence compiler warnings about unused parameter. */
> +  name = svn_path_basename (name, pool);
>    return (0 == strcmp (name, adm_dir_name)
>            || 0 == strcmp (name, default_adm_dir_name));
>  }

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Daniel Rall <dl...@finemaltcoding.com>.
On Thu, 27 Oct 2005, Daniel Rall wrote:
...
> The error occurs because "." is passed to svn_wc_is_adm_dir(), which
> eventually triggers the is_canonical() assertion failure in
> svn_path_basename().  add_dir_recursive(), the caller of
> svn_wc_is_adm_dir(), contains code which filters out empty, parent,
> and "." paths, but that code isn't executed in time.

Turns out the call to svn_path_basename() from svn_wc_is_adm_dir() was
a local hack I had in my working copy which was requested by the
Subclipse folks (I didn't see any comments on the patch when I last
posted it to list, but could've missed them).  Any objections to me
committing both patches?  I do have some concern that the previously
super-thin svn_wc_is_adm_dir() routines becomes heavier because of
this change.  Thoughts?


Index: subversion/libsvn_wc/adm_files.c
===================================================================
--- subversion/libsvn_wc/adm_files.c	(revision 17065)
+++ subversion/libsvn_wc/adm_files.c	(working copy)
@@ -57,7 +57,7 @@
 svn_boolean_t
 svn_wc_is_adm_dir (const char *name, apr_pool_t *pool)
 {
-  (void)pool;  /* Silence compiler warnings about unused parameter. */
+  name = svn_path_basename (name, pool);
   return (0 == strcmp (name, adm_dir_name)
           || 0 == strcmp (name, default_adm_dir_name));
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Philip Martin <ph...@codematters.co.uk>.
Daniel Rall <dl...@collab.net> writes:

> svn_io_dir_read() is documented as a thin wrapper around
> apr_dir_read().  Two things:
>
> 1) There are other functions (e.g. svn_io_get_dirents2) which might be
> more appropriate here because they already filter out "." and "..".

Yup, it may be necessary to rev the svn_io_dir_read interface, for
behavioural rather than ABI reasons.

> 2) Should the semantics of svn_io_dir_read() change such that it
> always does path canonicalization?

If I was writing it from scratch it would return canonicalised paths,
I don't think we should not be using non-canonical paths within the
library.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Daniel Rall <dl...@collab.net>.
On Fri, 28 Oct 2005, Philip Martin wrote:

> Daniel Rall <dl...@collab.net> writes:
... 
> > The error occurs because "." is passed to svn_wc_is_adm_dir(), which
> > eventually triggers the is_canonical() assertion failure in
> > svn_path_basename().  add_dir_recursive(), the caller of
> > svn_wc_is_adm_dir(), contains code which filters out empty, parent,
> > and "." paths, but that code isn't executed in time.
> 
> "." isn't a canonical path.  I think the error is that svn_io_dir_read
> should not be returning ".", it should convert it to "".

svn_io_dir_read() is documented as a thin wrapper around
apr_dir_read().  Two things:

1) There are other functions (e.g. svn_io_get_dirents2) which might be
more appropriate here because they already filter out "." and "..".

2) Should the semantics of svn_io_dir_read() change such that it
always does path canonicalization?
-- 

Daniel Rall

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Path canonicalization assertion failure triggered by add_dir_recursively()

Posted by Philip Martin <ph...@codematters.co.uk>.
Daniel Rall <dl...@collab.net> writes:

> The stack trace is as follows:
>
> #0  0x00365402 in __kernel_vsyscall ()
> #1  0x0085b1f8 in raise () from /lib/libc.so.6
> #2  0x0085c948 in abort () from /lib/libc.so.6
> #3  0x0085438e in __assert_fail () from /lib/libc.so.6
> #4  0x0031c3b4 in svn_path_basename (path=0x954e870 ".", pool=0x954e820)
>     at subversion/libsvn_subr/path.c:377
> #5  0x0040f8d1 in svn_wc_is_adm_dir (name=0x954e870 ".", pool=0x954e820)
>     at subversion/libsvn_wc/adm_files.c:60

Huh?  svn_wc_is_adm_dir doesn't call svn_path_basename.

> #6  0x00ef1793 in add_dir_recursive (
>     dirname=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir", adm_access=0x9540c28, force=0, no_ignore=0, ctx=0x9532e68, pool=0x95409d0)
>     at subversion/libsvn_client/add.c:331
> #7  0x00ef1a82 in add (
>     path=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir",
>     recursive=1, force=0, no_ignore=0, adm_access=0x9540c28, ctx=0x9532e68,
>     pool=0x95409d0) at subversion/libsvn_client/add.c:413
> #8  0x00ef1b9b in svn_client_add3 (
>     path=0x9533c58 "/home/dlr/src/subversion/working_copies/basic_test1/dir",
>     recursive=1, force=0, no_ignore=0, ctx=0x9532e68, pool=0x95409d0)
>     at subversion/libsvn_client/add.c:448
> #9  0x0804be42 in svn_cl__add (os=0x9532ab0, baton=0xbfb37818, pool=0x9532998)
>     at subversion/clients/cmdline/add-cmd.c:65
> #10 0x08052826 in main (argc=3, argv=0xbfb379c4)
>     at subversion/clients/cmdline/main.c:1503
>
> The error occurs because "." is passed to svn_wc_is_adm_dir(), which
> eventually triggers the is_canonical() assertion failure in
> svn_path_basename().  add_dir_recursive(), the caller of
> svn_wc_is_adm_dir(), contains code which filters out empty, parent,
> and "." paths, but that code isn't executed in time.

"." isn't a canonical path.  I think the error is that svn_io_dir_read
should not be returning ".", it should convert it to "".

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org