On Mon, Apr 21, 2008 at 2:36 PM, Daniel Shahaf <d.s_at_daniel.shahaf.co.il> wrote:
> Stefan Sperling noted on IRC that the svn command-line tools respond to
> errors in main() in different ways:
>
> 1. svn_handle_error2(force = False);
> 2. svn_handle_error2(force = True);
> 3. return svn_cmdline_handle_exit_error(svn_error_t *error);
> 4. SVN_INT_ERR(expr);
>
> which, respectively,
>
> 1. print an error chain and return to caller;
> (this call is sometimes used to print warnings)
> 2. print an error chain and abort();
> 3. Call svn_handle_error2(@a error, stderr, FALSE, @a prefix), clear
> @a error, destroy @a pool iff it is non-NULL, and return
> EXIT_FAILURE;
> 4. Evaluate @a expr. If it yields an error, handle that error and
> return @c EXIT_FAILURE.
>
> svn_handle_error2 has the following comment:
>
> if (fatal)
> /* XXX Shouldn't we exit(1) here instead, so that atexit handlers
> get called? --xbc */
> abort();
>
> Further, in r24415 Malcolm Rowe converted numerous exit paths to use
> svn_cmdline_handle_exit_error(), noting that that fixed error leaks and
> prevented aborts in maintainer mode. (If I understand correctly, the
> aborts were caused by exiting the process before destroying the
> top-level pool.)
>
> Given that aborts are bad, would it make sense to (a) implement xbc's
> comment quoted above; (b) change all exit paths of types (2) and (4) to
> use svn_cmdline_handle_exit_error, and document that for posterity?
>
> Daniel
>
>
> P.S. Stefan also suggested adding a warning to SVN_INT_ERR that it
> should not be used in a main() due to maintainer-mode aborts;
> I suggested a wording here: <http://paste.lisp.org/display/59488>.
Another somewhat ironic difference: SVN_INT_ERR hardcodes the error
prefix to be "svn: " (when it really should vary by the name of the
application)... and it's *only* used by tools *other* than 'svn'.
--dave
--
David Glasser | glasser@davidglasser.net | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-04-22 08:08:51 CEST