ECC-778: GRIB_IEEE_PACKING valgrind error

This commit is contained in:
Shahram Najm 2019-08-16 21:00:48 +01:00
parent d8ef570753
commit f28bbb9573
4 changed files with 44 additions and 15 deletions

View File

@ -1231,7 +1231,6 @@ long grib_get_decimal_scale_fact(double max, double min, long bpval, long binary
/* grib_templates.c */
grib_handle *grib_internal_template(grib_context *c, const char *name);
grib_handle *grib_internal_template(grib_context *c, const char *name);
grib_handle *grib_external_template(grib_context *c, const char *name);
grib_handle *bufr_external_template(grib_context *c, const char *name);
char *grib_external_template_path(grib_context *c, const char *name);
@ -1240,6 +1239,7 @@ char *grib_external_template_path(grib_context *c, const char *name);
grib_handle *grib_handle_of_accessor(grib_accessor *a);
void grib_dependency_add(grib_accessor *observer, grib_accessor *observed);
void grib_dependency_remove_observed(grib_accessor *observed);
int _grib_dependency_notify_change(grib_handle* h, grib_accessor* observed);
int grib_dependency_notify_change(grib_accessor *observed);
void grib_dependency_remove_observer(grib_accessor *observer);
void grib_dependency_observe_expression(grib_accessor *observer, grib_expression *e);

View File

@ -141,6 +141,34 @@ int grib_dependency_notify_change(grib_accessor* observed)
return ret;
}
/* This version takes in the handle so does not need to work it out from the 'observed' */
/* See ECC-778 */
int _grib_dependency_notify_change(grib_handle* h, grib_accessor* observed)
{
grib_dependency *d = h->dependencies;
int ret = GRIB_SUCCESS;
/*Do a two pass mark&sweep, in case some dependencies are added while we notify*/
while(d)
{
d->run = (d->observed == observed && d->observer != 0);
d = d->next;
}
d = h->dependencies;
while(d)
{
if(d->run)
{
/*printf("grib_dependency_notify_change %s %s %p\n",observed->name,d->observer ? d->observer->name : "?", (void*)d->observer);*/
if( d->observer && (ret = grib_accessor_notify_change(d->observer,observed))
!= GRIB_SUCCESS) return ret;
}
d = d->next;
}
return ret;
}
void grib_dependency_remove_observer(grib_accessor* observer)
{
grib_handle *h = handle_of(observer);

View File

@ -626,7 +626,8 @@ static int _grib_set_double_array_internal(grib_handle* h,grib_accessor* a,
err = grib_pack_double(a, val + *encoded_length, &len);
*encoded_length += len;
if(err == GRIB_SUCCESS){
return grib_dependency_notify_change(a);
/* See ECC-778 */
return _grib_dependency_notify_change(h, a);
}
}
else {
@ -662,7 +663,7 @@ static int _grib_set_double_array(grib_handle* h, const char* name,
err = GRIB_ARRAY_TOO_SMALL;
if(err == GRIB_SUCCESS)
return grib_dependency_notify_change(a);
return _grib_dependency_notify_change(h,a); /* See ECC-778 */
return err;
}

View File

@ -43,18 +43,17 @@ ${tools_dir}/grib_set -r -s packingType=grid_ieee $outsimple $out32
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
diff $out32.txt ${data_dir}/ieee_test.good
# Disabled for now. See GRIB-2 and GRIB-80
#GRIB_IEEE_PACKING=32
#export GRIB_IEEE_PACKING
#${tools_dir}/grib_filter -o $out32 w.filter $infile
#${tools_dir}/grib_filter r.filter $out32 > $out32.txt
#diff $out32.txt ${data_dir}/ieee_test.good
GRIB_IEEE_PACKING=32
export GRIB_IEEE_PACKING
${tools_dir}/grib_filter -o $out32 w.filter $infile
${tools_dir}/grib_filter r.filter $out32 > $out32.txt
diff $out32.txt ${data_dir}/ieee_test.good
#GRIB_IEEE_PACKING=64
#export GRIB_IEEE_PACKING
#${tools_dir}/grib_filter -o $out64 w.filter $infile
#${tools_dir}/grib_filter r.filter $out64 > $out64.txt
#diff $out64.txt ${data_dir}/ieee_test.good
GRIB_IEEE_PACKING=64
export GRIB_IEEE_PACKING
${tools_dir}/grib_filter -o $out64 w.filter $infile
${tools_dir}/grib_filter r.filter $out64 > $out64.txt
diff $out64.txt ${data_dir}/ieee_test.good
rm -f $outsimple $out32 $out64 $out32.txt $out64.txt
rm -f ${data_dir}/$outsimple.txt ${data_dir}/$out32.txt ${data_dir}/$out64.txt
@ -68,7 +67,8 @@ ${tools_dir}/grib_filter r.filter ${shdata}_ieee > $shdata.txt
diff $shdata.txt $shdata.good
rm -f ${shdata}_ieee
##########################
##################################
# Disabled for now. Infinite loop
#GRIB_IEEE_PACKING=32
#export GRIB_IEEE_PACKING
#${tools_dir}/grib_copy -r $shdata ${shdata}_32