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

RE: malformed argument re-use in svn_client_url_from_path2

From: Maximo, Andre (GE Global Research) <maximo_at_ge.com>
Date: Tue, 29 Oct 2013 11:29:30 +0000

Hi Ben and Bert,

  thanks for the feedback. The crashing problem was in fact poor handling of memory pools, as Bert suggested, and now it is fixed. There is no bug in svn_client_url_from_path2.

Best,
  Andre.

-----Original Message-----
From: Maximo, Andre (GE Global Research)
Sent: Friday, October 25, 2013 10:31 AM
To: 'Ben Reser'; Bert Huijben; users_at_subversion.apache.org
Subject: RE: malformed argument re-use in svn_client_url_from_path2

Thanks Bert again and Ben for joining.

  I am handling the error in the code (I just omitted for clarity), but the execution I am describing never throws an error. I also have tested passing the same pool and using the GetBuffer() method, but down to the same segfault at the svn_client_url_from_path2() call. Here is the updated code:

void CVCS::svnURLPath(CString& urlPath, const CString& fullPath)
{
  CError svnErr;
  const char *url = NULL;
  CString path(fullPath);
  svnErr.err = svn_client_url_from_path2(&url, path.GetBuffer(), m_svn_ctx, m_svn_pool, m_svn_pool);
  if (svnErr.err != NULL)
    throw svnErr;
  if (url != NULL)
    urlPath = CString(url);
}

  When I pass fullPath = "C:\\WD", an error is thrown with the message: "'C:\WD' is not a working copy" (ok here, don't think it was a fluke). I then checkout from the repository to it and update it using SVN api (all ok), now "C:\WD" exists and when I call svnURLPath on it, the url is returned fine.
  I try to find another path inside it, like fullPath = "C:\\WD\\History Items\\Documents\\File.txt". The behavior I expect is an error thrown saying this path does not exist in the repository (because it really still doesn't), but the execution just crashes inside svnURLPath, more specifically in the svn_client_url_from_path2(). (I also tested with a more simple fullPath = "C:\\WD\\Test" and crashes the same). Looking at this function I notice the svn_dirent_get_absolute() call with the same "path_or_url" argument and jumped to the conclusion that this was the problem. But it may well be the second function svn_wc__node_get_url(), getting lost with an unknown path. I am not, maybe it is a Windows specific problem?

Best,
  Andre.

-----Original Message-----
From: Ben Reser [mailto:ben_at_reser.org]
Sent: Thursday, October 24, 2013 6:36 PM
To: Maximo, Andre (GE Global Research); Bert Huijben; users_at_subversion.apache.org
Subject: Re: malformed argument re-use in svn_client_url_from_path2

On 10/24/13 11:44 AM, Maximo, Andre (GE Global Research) wrote:
> void CVCS::svnURLPath(CString& urlPath, const CString &fullPath)
>
> {
>
> apr_pool_t *local_pool = svn_pool_create(m_svn_pool);
>
> const char *url = NULL;
>
> svn_error_t *err = svn_client_url_from_path2(&url, fullPath, m_svn_ctx,
> m_svn_pool, local_pool);
>
> if (url != NULL)
>
> urlPath = CString(url);
>
> svn_pool_destroy(local_pool);
>
> }

Looking at this code more closely I see that you're passing
svn_client_url_from_path2() a pointer to a CString class. I'm guessing you're
using MFC based on that class name. So I suspect what you really needed on the
svn_client_url_from_path2() call is:

svn_error_t *err = svn_client_url_from_path2(&url, fullPath->GetBuffer(),
m_svn_ctx, m_svn_pool, local_pool);

Bert's and my earlier points about the lack of checking for errors still
stands. In this case our particular implementation is good enough that it
wouldn't break your code since url will still be NULL. But we don't promise that.

I think the fact that it's succeeding for you when passing a valid path is a
fluke and failing when passing a non-existent path is just a fluke.
Received on 2013-10-29 12:30:16 CET

This is an archived mail posted to the Subversion Users mailing list.

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