-
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
ncgen crashes on particular cdl file #323
Comments
Starting diagnosis in init_types. |
Size is being computed in semantics.c:computesize(), ~line |
This reeks of some kind of padding issue. Like where the double field needs a 64-bit aligned address or something. |
I had to switch gears after identifying the line in semantics.c, but I suspect you are correct. |
On what os are you running this? Under cygwin on x86, it does not fail for me. |
Running on macOS, 64-bit. Do you really mean x86, or is it x86-64? |
I've tested on Linux and OSX, both 64-bit |
The issue is probably compiler related and involves On 10/28/2016 4:27 PM, Ryan May wrote:
|
Created a branch, |
@dmh were you able to get access to a 64-bit environment? |
Not yet. If you want to take a stab at it, the probable On 11/14/2016 11:22 AM, Ward Fisher wrote:
|
note-to-self: semantics.c:640. |
Read: start, += getpadding(), += field->typesize
Clearly, order matters when computing padding/offset, and the latter order crashes hdf5 for some reason. Should it? Probably not. |
Looking at the C code generated by ncgen, it uses the |
The problem is compile-time vs run time. The c-code can use On 11/14/2016 3:24 PM, Ward Fisher wrote:
|
BTW, order sometimes does matter (though rarely). The reason all of this is important is that netcdf-4 tried to make it possible to define a I should note that there is undocumented code (ncaux.[ch]) that allows a user to |
Breadcrumbs: Section 4.3.2.1 |
I need to check to see what Visual Studio does; I hope it also adheres to gcc rules but who knows, considering all the other weird stuff they've done. |
Misc. notes:
That squares with what my understanding but I'll have to turn to other sources for a definitive source. This also explains why UPDATE: I corrected my fix (I was using the wrong variable to compute the "largest alignment multiplier"). Correcting this corrected the failures previously reported re: |
Cleanup todo listScratchpad for temporary files in netcdf-c/ that need to be addressed before merging into master.
|
Testing on ARM, Windows (with visual studio) appear to be working so far. Assuming these work, I will see about issuing a pull request to make code review easier. |
I pushed a branch called issue323.dmh.
|
Hi Dennis, The output is below. I've also gotten something that appears to be fixing Here's the output: null : size= 0 alignment= 0 On Tue, Nov 15, 2016 at 3:20 PM, DennisHeimbigner notifications@github.com
|
I think the situation is a lot worse than I realized.
On 11/15/2016 3:24 PM, Ward Fisher wrote:
|
I've tested 1 & 2 and haven't had a problem reading either; I tested branch I thought the file offsets were handled by the I/O layer; otherwise, wouldn't netCDF4 files have never been machine-independent in the first place? I'll test these on Windows as well, and ARM when I'm in the office tomorrow. |
Update: The files are reading just fine between platforms, but are being written differently. Specifically, it is being written incorrectly on the 64-bit platform. So, more work is needed. Written on 32-bit platform:
Written on 64-bit platform
The results remain the same whether I read from a 32-bit or 64-bit platform. |
Note this netcdf API function: |
Hi Dennis; I had noticed the nc_insert_compound() function; when I looked into what the HDF5 function was doing, they were also using the |
Additionally, I notice the tests in |
Ok, current status; the crash is gone but, on 64-bit systems, data is getting scrambled in the CDL file as represented above. The fix is the same as it was for the crash; moving the float below the double solves the issue. |
This is all beginning to come back. I did an H5Dump on a netcdf-4 file |
Also, let me make sure I understand. You seem to be saying that even when you round up |
So I was looking at the code in semantics.c and it seems to do what you |
Note from meeting w/ Dennis: probably something in the byte buffer construction code. It looks like the first 4 bytes of the data array (starting at the second element) are being discarded. |
Ok, I am testing a fix now. Sadly, I was not only mishandling padding between |
Thanks Dennis, I did a spot test on my end and, under cmake at least, everything appears to be fixed. I'll wait for travis to confirm the fix, and assuming everything passes I'll flesh out the release notes as well as making sure that all the test scripts are checking the output when ncgen is run. |
distcheck passed, so I guess we are just waiting on travis. |
Travis has passed, as has 32-bit ARM. Testing on Windows now with Visual Studio (32, 64 bit). Will continue to flesh out tests and such, but assuming I don't find any failures I will merge into master and create a maintenance release ASAP. |
As an aside, are you interested in AppVeyor as a Travis-like thing for windows? I can help get you set up--I'm just no good at windows building. |
(I have a Unidata org for it) |
@dopplershift possibly! I'll investigate it and follow up with you; the required dependencies are the only thing I wonder about. |
Apparently I never closed this; reviewing to ensure it's solved and then closing. |
The following CDL crashes when
ncgen -k nc4 [filename]
is executed on it:Moving
temperature
beforetime
resolves the crash. Changing the type fromfloat
todouble
fixes the crash. Runningncgen -k nc4 -l c test.cdl > test.c
, compiling and runningtest.c
generates a proper binary netcdf file as well.Log files were generated for each run, and captured below. The issue appears to be that, in the failure case, the size of the compound type is incorrectly computed as
28
instead of32
.ncgen_temp_moved_below_time.out.txt
ncgen.out.txt
test.out.txt
The text was updated successfully, but these errors were encountered: