You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Craig Peterein <cr...@myrealbox.com> on 2002/01/05 12:59:10 UTC

[PATCH] fix core and make tests pass

The following tests failed:

$ make check
...
Running all tests in svn-test2.sh...svn-test2.sh: line 148:  8242 Segmentation fault      ${SVN_PROG} commit --xml-file ${COMMIT_RESULTFILE_NAME}-1.xml --revision 24 ${TEST_DIR_1} --message "24 slices of American cheese"
Running all tests in svn-test.sh...svn-test.sh: line 80:  8338 Segmentation fault      ../${SVN_PROG} commit --xml-file ../${COMMIT_RESULTFILE_NAME}-2.xml --revision 2
...

Here's the relevant parts of tests.log:

Attempting to commit again, with conflicts removed.
Oops, problem: 15
END: svn-test2.sh

Committing changes in t1.
Oops, problem: 6
END: svn-test.sh

and the backtrace:

#0  0x402ed486 in apr_pstrdup (a=0x8055b30, s=0x6 <Address 0x6 out of bounds>) at apr_strings.c:79
#1  0x4001c92e in send_to_repos (committed_rev=0xbffff470, committed_date=0xbffff46c, committed_author=0xbffff468, before_editor=0x0, 
    before_edit_baton=0x0, after_editor=0x8057920, after_edit_baton=0x8057918, base_dir=0x8057a70, condensed_targets=0x8057a80, url=0x0, 
    new_entry=0x0, auth_baton=0x8055d58, log_msg=0x0, xml_dst=0x8055d10, revision=2, pool=0x8055b30) at subversion/libsvn_client/commit.c:631
#2  0x4001caf9 in svn_client_commit (committed_rev=0xbffff470, committed_date=0xbffff46c, committed_author=0xbffff468, before_editor=0x0, 
    before_edit_baton=0x0, after_editor=0x8057920, after_edit_baton=0x8057918, auth_baton=0x8055d58, targets=0x8055d28, log_msg=0x0, 
    xml_dst=0x8055d10, revision=2, pool=0x8055b30) at subversion/libsvn_client/commit.c:728
#3  0x0804a09b in svn_cl__commit (os=0x8055cb0, opt_state=0xbffff4d0, pool=0x8055b30) at subversion/clients/cmdline/commit-cmd.c:110
#4  0x0804cf9f in main (argc=6, argv=0xbffff5b4) at subversion/clients/cmdline/main.c:610
#5  0x403b965f in __libc_start_main () from /lib/libc.so.6


 * commit-cmd.c (svn_cl__commit): Initialize date and author to NULL to prevent
 core and make tests pass (svn-test.sh and svn-test2.sh)

Index: ./subversion/clients/cmdline/commit-cmd.c
===================================================================
--- ./subversion/clients/cmdline/.svn/text-base/commit-cmd.c.svn-base	Thu Jan  3 19:58:34 2002
+++ ./subversion/clients/cmdline/commit-cmd.c	Sat Jan  5 06:34:53 2002
@@ -52,6 +52,8 @@
   const char *date;      /* Server-side date of the commit. */
   const char *author;    /* Server-side author of the commit. */
 
+  date = NULL;
+  author = NULL;
   /* Take our message from ARGV or a FILE */
   if (opt_state->filedata) 
     message = opt_state->filedata;

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

Re: [PATCH] fix core and make tests pass

Posted by Ben Collins-Sussman <su...@collab.net>.
Philip Martin <ph...@codematters.co.uk> writes:

> The client creates two unitialised pointers, and passes the address of
> these pointers into a function that will set the pointers. Sometimes
> the function fails to do that and the pointers remain unitialised. If
> you initialise them before passing them in you fix the problem here,
> but if the function ever gets called anywhere else you will have to
> remember to initialise them there as well. If you initialise them
> inside the function it only needs to be done in one place.

Yeah, duh, thanks.  :-)   I realized what you were saying right after
I sent my last mail, heh.

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

Re: [PATCH] fix core and make tests pass

Posted by Philip Martin <ph...@codematters.co.uk>.
Ben Collins-Sussman <su...@collab.net> writes:

> > If we choose to initialise to null, which looks like a hack to me, it
> > should be done in libsvn_client/commit.c:send_to_repos.  Something
> > like
> > 
> >    if (committed_date)
> >      *committed_date = NULL;
> 
> I'm not following you here.  The command-line client creates two
> uninitialzed pointers.  It passes the addresses of these pointers all
> the way down through libsvn_client and into the RA layer.  The RA
> layer allocates memory and sets the pointers.  
> 
> So what's wrong if the original pointers start out as NULL?  When we
> commit to XML, no RA layer will ever change them, and thus the current
> code at the end of libsvn_client's send_to_repos() will avoid trying
> to dup their values.
> 
> Please explain the issue, I'm not sure I understand the problem.
> Otherwise, I'll just go ahead and commit the NULL initializations.

The client creates two unitialised pointers, and passes the address of
these pointers into a function that will set the pointers. Sometimes
the function fails to do that and the pointers remain unitialised. If
you initialise them before passing them in you fix the problem here,
but if the function ever gets called anywhere else you will have to
remember to initialise them there as well. If you initialise them
inside the function it only needs to be done in one place.

-- 
Philip

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

Re: [PATCH] fix core and make tests pass

Posted by Ben Collins-Sussman <su...@collab.net>.
Philip Martin <ph...@codematters.co.uk> writes:

> "Craig Peterein" <cr...@myrealbox.com> writes:
>
> > +  date = NULL;
> > +  author = NULL;
>
> I don't think that is quite right. svn_client_commit writes to data
> and author, requiring the caller to initialise them first is ugly.

I'm getting this same segfault too in r745, every time we try to
commit to XML.

> ra_local commit does this at lines 126 to 141 in ra_local/ra_plugin.c.
> Perhaps --xml-file and ra_dav commits need something similar?

No, in the case of commits to XML, it's already silly that we're
artifically specifying a revision number on the command-line.  There's
no need to worry about making this already-artificial situation start
returning more imaginary information from an imaginary RA layer.

> If we choose to initialise to null, which looks like a hack to me, it
> should be done in libsvn_client/commit.c:send_to_repos.  Something
> like
> 
>    if (committed_date)
>      *committed_date = NULL;

I'm not following you here.  The command-line client creates two
uninitialzed pointers.  It passes the addresses of these pointers all
the way down through libsvn_client and into the RA layer.  The RA
layer allocates memory and sets the pointers.  

So what's wrong if the original pointers start out as NULL?  When we
commit to XML, no RA layer will ever change them, and thus the current
code at the end of libsvn_client's send_to_repos() will avoid trying
to dup their values.

Please explain the issue, I'm not sure I understand the problem.
Otherwise, I'll just go ahead and commit the NULL initializations.

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

Re: [PATCH] fix core and make tests pass

Posted by Philip Martin <ph...@codematters.co.uk>.
"Craig Peterein" <cr...@myrealbox.com> writes:

>  * commit-cmd.c (svn_cl__commit): Initialize date and author to NULL to prevent
>  core and make tests pass (svn-test.sh and svn-test2.sh)
> 
> Index: ./subversion/clients/cmdline/commit-cmd.c
> ===================================================================
> --- ./subversion/clients/cmdline/.svn/text-base/commit-cmd.c.svn-base	Thu Jan  3 19:58:34 2002
> +++ ./subversion/clients/cmdline/commit-cmd.c	Sat Jan  5 06:34:53 2002
> @@ -52,6 +52,8 @@
>    const char *date;      /* Server-side date of the commit. */
>    const char *author;    /* Server-side author of the commit. */
>  
> +  date = NULL;
> +  author = NULL;
>    /* Take our message from ARGV or a FILE */
>    if (opt_state->filedata) 
>      message = opt_state->filedata;

I don't think that is quite right. svn_client_commit writes to data
and author, requiring the caller to initialise them first is ugly.  An
ra_local commit does this at lines 126 to 141 in ra_local/ra_plugin.c.
Perhaps --xml-file and ra_dav commits need something similar?

If we choose to initialise to null, which looks like a hack to me, it
should be done in libsvn_client/commit.c:send_to_repos.  Something
like

   if (committed_date)
     *committed_date = NULL;

-- 
Philip

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