You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Philip Martin <ph...@wandisco.com> on 2011/11/23 13:51:23 UTC
Re: svn commit: r1204489 - /subversion/trunk/subversion/libsvn_client/merge.c
julianfoad@apache.org writes:
> Author: julianfoad
> Date: Mon Nov 21 13:38:13 2011
> New Revision: 1204489
>
> URL: http://svn.apache.org/viewvc?rev=1204489&view=rev
> Log:
> Move more variables to a smaller scope and fix uninitialized output
> parameters in callback functions. The variables previously had
> initializers which were only necessary because the callbacks didn't
> always initialize all their outputs as they should. This change might be
> expected to cause a behaviour change, since the initialization was
> previously happening only once before the first iteration of the loop.
> I have checked fairly thoroughly and it seems in the cases where
> outputs weren't initialized they weren't tested or the loop terminated
> or there was some other compensating effect.
> @@ -6726,9 +6735,6 @@ do_file_merge(svn_mergeinfo_catalog_t re
> apr_pool_t *scratch_pool)
> {
> apr_array_header_t *remaining_ranges;
> - svn_wc_notify_state_t prop_state = svn_wc_notify_state_unknown;
> - svn_wc_notify_state_t text_state = svn_wc_notify_state_unknown;
> - svn_boolean_t tree_conflicted = FALSE;
> svn_client_ctx_t *ctx = merge_b->ctx;
> const char *mergeinfo_path;
> svn_merge_range_t range;
> @@ -6855,6 +6861,8 @@ do_file_merge(svn_mergeinfo_catalog_t re
> svn_string_t *pval;
> const char *mimetype1, *mimetype2;
> apr_array_header_t *propchanges;
> + svn_wc_notify_state_t prop_state, text_state;
> + svn_boolean_t tree_conflicted = TRUE;
>
> svn_pool_clear(iterpool);
valgrind is giving me an unitialised memory read error in notify() for
the property state during update_tests.py 36.
do_file_merge calls merge_file_changed which calls merge_props_changed
and inside merge_props_changed props->nelts is zero so the state is not
set.
Do we solve this by initialising prop_state? To what value? Or do we
make merge_props_changed set it when props->nels is zero? To what value?
--
Philip
Re: svn commit: r1204489 - /subversion/trunk/subversion/libsvn_client/merge.c
Posted by Julian Foad <ju...@btopenworld.com>.
Philip Martin wrote:
> The simple patch:
>
[...]
> + else if (state)
> + *state = svn_wc_notify_state_unchanged;
[...]
>
> does fix the valgrind warning.
Thanks Philip.
- Julian
Re: svn commit: r1204489 - /subversion/trunk/subversion/libsvn_client/merge.c
Posted by Philip Martin <ph...@wandisco.com>.
Philip Martin <ph...@wandisco.com> writes:
>> Do we solve this by initialising prop_state? To what value? Or do we
>> make merge_props_changed set it when props->nels is zero? To what value?
>
> Also, looking at merge_file_changed: after the call to
> merge_props_changed a tree conflict causes a return without setting text
> state. This code has so many branches it's hard to determine that all
> paths set these values. Perhaps initialising them early is better?
The simple patch:
Index: subversion/libsvn_client/merge.c
===================================================================
--- subversion/libsvn_client/merge.c (revision 1205355)
+++ subversion/libsvn_client/merge.c (working copy)
@@ -1254,6 +1254,8 @@ merge_props_changed(svn_wc_notify_state_t *state,
else if (err)
return svn_error_trace(err);
}
+ else if (state)
+ *state = svn_wc_notify_state_unchanged;
return SVN_NO_ERROR;
}
does fix the valgrind warning.
--
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com
Re: svn commit: r1204489 - /subversion/trunk/subversion/libsvn_client/merge.c
Posted by Philip Martin <ph...@wandisco.com>.
Philip Martin <ph...@wandisco.com> writes:
> julianfoad@apache.org writes:
>
>> Author: julianfoad
>> Date: Mon Nov 21 13:38:13 2011
>> New Revision: 1204489
>>
>> URL: http://svn.apache.org/viewvc?rev=1204489&view=rev
>> Log:
>> Move more variables to a smaller scope and fix uninitialized output
>> parameters in callback functions. The variables previously had
>> initializers which were only necessary because the callbacks didn't
>> always initialize all their outputs as they should. This change might be
>> expected to cause a behaviour change, since the initialization was
>> previously happening only once before the first iteration of the loop.
>> I have checked fairly thoroughly and it seems in the cases where
>> outputs weren't initialized they weren't tested or the loop terminated
>> or there was some other compensating effect.
>
>> @@ -6726,9 +6735,6 @@ do_file_merge(svn_mergeinfo_catalog_t re
>> apr_pool_t *scratch_pool)
>> {
>> apr_array_header_t *remaining_ranges;
>> - svn_wc_notify_state_t prop_state = svn_wc_notify_state_unknown;
>> - svn_wc_notify_state_t text_state = svn_wc_notify_state_unknown;
>> - svn_boolean_t tree_conflicted = FALSE;
>> svn_client_ctx_t *ctx = merge_b->ctx;
>> const char *mergeinfo_path;
>> svn_merge_range_t range;
>> @@ -6855,6 +6861,8 @@ do_file_merge(svn_mergeinfo_catalog_t re
>> svn_string_t *pval;
>> const char *mimetype1, *mimetype2;
>> apr_array_header_t *propchanges;
>> + svn_wc_notify_state_t prop_state, text_state;
>> + svn_boolean_t tree_conflicted = TRUE;
>>
>> svn_pool_clear(iterpool);
>
> valgrind is giving me an unitialised memory read error in notify() for
> the property state during update_tests.py 36.
>
> do_file_merge calls merge_file_changed which calls merge_props_changed
> and inside merge_props_changed props->nelts is zero so the state is not
> set.
>
> Do we solve this by initialising prop_state? To what value? Or do we
> make merge_props_changed set it when props->nels is zero? To what value?
Also, looking at merge_file_changed: after the call to
merge_props_changed a tree conflict causes a return without setting text
state. This code has so many branches it's hard to determine that all
paths set these values. Perhaps initialising them early is better?
--
uberSVN: Apache Subversion Made Easy
http://www.uberSVN.com