[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #DMO-236308]: NETCDF Segmentation fault issue with large data sizes



Hello David,

I'm uncertain if the following is related to your error (as I'm unable to 
duplicate it) but I *did* find an error in the example code you had provided.  
The way the memory is currently being dynamically allocated does not guarantee 
that it will be contiguously allocated, resulting in a problem when the data is 
being written to disk.  If you change how the memory is allocated as follows, 
you should see the valgrind warnings eliminated.  Instead of having two malloc 
statements (one to allocate **data_out, another to allocate each 'row' of the 
2D array), use the following single malloc statement:

    int (*data_out)[NX] = malloc(sizeof *data_out * NY);

This will result in a contiguous block of memory being allocated.

Try making this change and let me know if this resolves the issue you were 
seeing.  If not, any info you can provide re: the systems you are developing on 
will be very useful!

Thank you,

-Ward

 


> Dear NETCDF support,
> 
> 
> When running the attached program I receive a segmentation fault on line 105. 
> I have run the binary through valgrind and believe this is because the 
> function nc_put_var_int is trying to place the array on the stack rather than 
> the heap and thus causing a stack overflow. Is there a way to fix this?
> 
> This has been tried on multiple systems using both the gcc and llvm compilers.
> 
> 
> Thanks
> 
> David Wilson
> 
> The Roslin Institute
> 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> 


Ticket Details
===================
Ticket ID: DMO-236308
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.