Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_FillValue attribute causing other attributes to be removed in some circumstances #239

Closed
WardF opened this issue Mar 22, 2016 · 4 comments

Comments

@WardF
Copy link
Member

WardF commented Mar 22, 2016

Originally reported to Unidata via Email:


I believe I have found a bug in the NetCDF C library, and I'm not sure of the best way to report it. I found your names on the Unidata staff listing.

It is related to NCF-187, (Fix bug resulting in segmentation violation when trying to add a _FillValue attribute to a variable in an existing netCDF-4 file defined without it.), which Russ Rew had fixed/closed about a year ago. We were seeing the SEGV in our software as well -- that no longer happens with NetCDF 4.4.0. However, now any previously existing attributes associated with the preexisting variable are wiped out, with only the newly added _FillValue attribute remaining.

I've traced rather extensively through the NetCDF and underlying HDF5 codes, and think I know why this happens. I don't have a good solution however:

i) The new _FillValue attribute is correctly added to the linked list of attributes associated with the variable (stackTrace0). It is marked as "dirty", and the variable itself is marked as having a new fill_value (fill_val_changed).

ii) When the file is closed, because "fill_val_changed" has been set, it is decided that the enitre variable ("dataset" in HDF5 parlance?) needs to be rewritten (stackTrace1).

iii) After the dataset is written, the list of attributes associated with the variable is traversed and attributes marked as "dirty" are added to the new dataset. However, only the newly added _FillValue has been marked as such, and consequently it is the only one written to the dataset (stackTrace2)

I hope this helps, and please let me know if I can help further.

Thanks!

@WardF WardF self-assigned this Mar 22, 2016
@WardF WardF added this to the 4.4.1 milestone Mar 22, 2016
@WardF
Copy link
Member Author

WardF commented May 31, 2016

Note to self: branch gh239. See nc4attr.c:nc4_put_att(), line 239.

@WardF
Copy link
Member Author

WardF commented Jun 7, 2016

Test added in branch gh239 for this issue.

@WardF
Copy link
Member Author

WardF commented Jun 10, 2016

TODO:

  • Update test to ensure that global attribute behavior is working properly, as well as variable attributes.

@WardF
Copy link
Member Author

WardF commented Jun 10, 2016

I've updated nc4hdf.c:write_var() so that when a variable has been created and the fill value changed (triggering a variable rewrite), all extant attributes associated with the var are flagged dirty ensuring that they are copied over. Tagging @DennisHeimbigner in case I'm missing something obvious.

@WardF WardF closed this as completed in 1ebb104 Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant