-
Notifications
You must be signed in to change notification settings - Fork 262
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
Increase number of mode flags for create/open #864
Comments
Another thought. I cannot see how ncdump will have a way to process files |
I don't think you will get a warning if you change the mode argument to "long long mode" and the client continues to pass an "int" since it is a widening conversion and there is no potential for loss of data. I made a similar change to exodus several years ago and it didn't result in any errors for clients that were still passing int instead of long long.
|
I think you are correct. Since in the API we always pass the mode by value, |
But only if the user code was compiled with the new API. Otherwise |
Correct. It may be good to add code similar to HDF5 and exodus which can detect when a client links to a library which is a different version than the include file / API they compiled against. I always hate when I get the warning/error about version mismatch, but it always points out a problem with my build, so I am glad it is there. |
@DennisHeimbigner I get now what you mean with ncdump. I have added a discussion under ticket #177. |
@gsjaardema excellent suggestion for using long long. Also I suggest you create an issue for your idea of noticing a mismatch between netCDF header and built library. Seems like a good idea. |
I have tried this out (converting mode flags to long long) and indeed it works well. No errors or warnings are emitted by any of the the test code, which reassures that this would be safe for users. @gsjaardema are you familiar with how HDF5 and exodus detect a library/header mismatch? I can add this to the netCDF build system(s) as well. |
The method that exodus uses which is similar to hdf5 is as follows:
In the compiled library, there is the following code:
Basically, in the library, the The HDF5 version is more complex and lets the user specify an environment variable to ignore the version check. This method introduces a little confusion for debugging since there is no 'ex_open() |
That seems kind of ugly to me. What are we trying to catch? A user does a yum update netcdf-dev and gets a new library version. Then he uses a netcdf.h file that he has squirreled away somewhere from a previous version? Why would the user do such a thing? How does it come about? |
Or, the user has multiple installations using different compilers; some parallel, some serial. During the build process, or at runtime if using shared libraries, the path to the library is specified incorrectly and the include file doesn't match the library. Typically more frequent at runtime with shared libraries when the LD_LIBRARY_PATH is incorrect and the path wasn't compiled in. I guess we have different definitions of "ugly" vs "simple easy check that catches stupid mistakes in a few lines of code and eliminates a few hours of debugging" |
OK, I can understand how it can happen with multiple installations and an incorrect LD_LIBRARY_PATH. I've done that myself. |
Please don't do this - I've been fighting for years to get HDF5 to drop the header version check. Instead do proper ABI management via soname, symbol versioning, etc. |
Pardon if I repeat. The issue we are trying to solve is this:
|
Actually it will work just fine to increase the size of the type the nc_open/nc_create command. Existing C code will automatically promote an int to a long long, so existing code will work. We will have to change the Fortran library to handle the new type size, so people will have to upgrade their C library when upgrading their fortran library (which they should be doing anyway - no one should be using a new fortran library with an old C library, that is not guaranteed to work.) So I believe we can just increase the size of the mode parameter and start making use of the extra 32 bits for additional mode flags. As @opoplawski alludes, using the proper ABI management (which we do) will allow client programs to know that they must recompile to use the new version of the library. Static library users will already understand that they have to re-compile to get a new version of the library in use. @opoplawski I would be very interested in hearing what you don't like about the HDF5 header version check. |
One point to clarify. Remember that we will be dealing with compiled code |
@DennisHeimbigner this issue is solved by increasing the so version number, which will then cause client programs to not use the library as a drop-in binary replacement. Recompile will be required to use the new version of the library. This is all part of the shared-library facility. So we don't have to worry about that, as long as we remember to correctly increment the so number. |
Not quite. That is why the header version info is required. I can, for example, |
@DennisHeimbigner I understand your point. Mismatches between header and library are possible. My point is that changing the API, with shared library builds, will prevent binary code mismatches if they are using the correct header (as they are supposed to be doing). I have started a new issue for just the header version checking. If there is a consensus that it is a good idea I will be happy to implement. If it is to be implemented, I'm happy to do so, and then increase the size of the mode flag. If it is not to be implemented, I can just change the mode flags. Ether way, it's fine by me. ;-) |
I do not know about you, but I have hit the HDF5 version mismatch error on a number of |
@opoplawski this topic has come to the fore. Can you give a more detailed explanation of why you think HDF5 should drop the header check? (I will communicate this explanation to the HDF5 team as well, we were just discussing this today.) |
So basically, the verification process should involve something like this:
|
If the lib file holds the version number in a global var and the version number is in netcdf.h, then those could be compared. Is that what you mean? The library global var is fixed when it is compiled, so if the user builds with a different netcdf.h, the library can throw an error. But I am not sure this is necessary. Lots of trouble is taken to ensure that the netcdf.h files is backward compatible, so using a newer one will not break anything. And using an older one, which does not contain a prototype or constant, the user will get a compile error. So what does checking the header version really do? |
The problem case is this:
|
You know what, let me try it out a bit today on a branch and we will see what we can make happen. @opoplawski still eager to get your input on this, since you were the one who raised the objection... |
In any case, when/if we expand the size of the mode flag, we should
|
The proper way to signal the version of the ABI is with the library's soname/soversion. When the library's ABI changes, you bump the SO version. Otherwise you leave it alone and let previously linked programs take advantage of any bug fixes in a compatible update. Conflating the library's release version with the API/ABI is a mistake - and one that I recently argued against netcdf from making itself. See also https://autotools.io/libtool/version.html and https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
Thanks @opoplawski ; the second link you provide is the guide I use during a release to update the SO version. I use the ABI reporting tool to generate a change report between the previous version and pending release version and, based on the information therein, update the SO version according to the gnu.org recommended guidelines. |
OK, to summarize, there is a tricky method used by HDF5 to check version of header and compiled library. However, it monkeys with the usual shared library system, which already allows for the fact that sometimes the compiled library may be updated, and everything is still compatible, so we should all chill. I believe the conclusion is that we should NOT do the header version checking. I think we have a convincing case here that this is a step too clever. Though it sometimes reveals a problem, other times it causes a problem. So we should not use it and rely on other methods for the user to use the correct header file. I will also note that with the rareness of changes to the netCDF API, the danger of using a different header file is quite minimal. This is not as true for HDF5, where they change things more frequently. |
I would agree with the summary @edhartnett presents above, for the reasons he succinctly states. We would be potentially trading one set of issues for a whole new set of issues that my gut tells me we would encounter far more often. |
Ed- I would appreciate some clarification. You write:
|
One topic that came up in #177 was the upcoming scarcity of mode flags. I don't wish that complex conversation to get mixed up with #177, so I started this issue to dicuss.
After PIO and user-defined formats are added, I have this:
Not too many open slots left! What happens when we run out? Currently we have:
I don't think we can change this prototype without introducing warnings in user code.
Some possibilities:
Or
Not an immediate issue, but just capturing discussion up to now.
The text was updated successfully, but these errors were encountered: