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

Warning from GCC's -Walloc-size-larger-than= in H5Location.cpp #5126

Open
avitase opened this issue Nov 16, 2024 · 10 comments
Open

Warning from GCC's -Walloc-size-larger-than= in H5Location.cpp #5126

avitase opened this issue Nov 16, 2024 · 10 comments
Assignees
Labels
Component - C++ C++ wrappers Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality

Comments

@avitase
Copy link

avitase commented Nov 16, 2024

My g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0 compiler warns me about a dangerous alloc in

char *name_C = new char[actual_name_len]();

This is the warning I got:

hdf5/c++/src/H5Location.cpp:2001:46: warning: argument 1 range [9223372036854775809, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
 2001 |     char *name_C = new char[actual_name_len]();
      |                                              ^
In file included from /usr/include/c++/13/bits/exception_ptr.h:38,
                 from /usr/include/c++/13/exception:164,
                 from /usr/include/c++/13/ios:41,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from /home/avitase/ravis/core/hdf5/c++/src/H5Location.cpp:13:
/usr/include/c++/13/new:128:26: note: in a call to allocation function ‘void* operator new [](std::size_t)’ declared here
  128 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |  
@bmribler bmribler self-assigned this Nov 18, 2024
@bmribler bmribler added the Component - C Library Core C library issues (usually in the src directory) label Nov 18, 2024
@bmribler
Copy link
Contributor

Hello! This seemed to be an issue with the C API that was used in the C++ code, and we're working on it.
I should let you know that the C++ interface will be discontinued with HDF5 2.0.0, scheduled to be released in March, and there are much better alternatives exist, such as HighFive. Please consider that option.

@avitase
Copy link
Author

avitase commented Nov 18, 2024

Thanks for your response and the suggestion to abandon the C++ interface. We considered using HighFive but eventually we decided that for our simple use case relying on yet another third party dependency is not worth it. Am I right that HighFive is not part of HDFGroup or is maintained by you / them?

@derobins
Copy link
Member

HighFive is not currently maintained by the HDF Group. The C++ wrappers will probably be removed from the HDF5 library in December or January.

@avitase
Copy link
Author

avitase commented Nov 18, 2024

@derobins, thanks for your response. Personally, I find it handy to have a thin C++ wrapper that takes care of the RAII. However, I assume that there are reasons for deprecating the API. Since we cannot easily add dependencies to our project this means that we have to write these wrappers by ourselves, though.

@derobins derobins added Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Component - C++ C++ wrappers Type - Improvement Improvements that don't add a new feature or functionality and removed Component - C Library Core C library issues (usually in the src directory) labels Nov 19, 2024
@bmribler
Copy link
Contributor

I'm sorry, @avitase, the C++ wrapper has not been maintained for quite a while now. While you write your own wrappers, you're welcome to use the C++ wrapper code in any way if it's helpful.

@bmribler
Copy link
Contributor

bmribler commented Dec 1, 2024

Hi @avitase, I'm trying to make sure that the call to H5Lget_name_by_idx before
2001 | char *name_C = new char[actual_name_len]();
returns a reasonable value for name_len. Could you tell me how you got to that position? If it's your program that calls H5Location::getObjnameByIdx(), would you be able to share the data file? Thanks!

@avitase
Copy link
Author

avitase commented Dec 2, 2024

Hi @avitase, I'm trying to make sure that the call to H5Lget_name_by_idx before 2001 | char *name_C = new charactual_name_len; returns a reasonable value for name_len. Could you tell me how you got to that position? If it's your program that calls H5Location::getObjnameByIdx(), would you be able to share the data file? Thanks!

Hi @bmribler, I include HDF5 as a dependency in my CMake super-build. Hence, this error occurs during the compilation of HDF5 itself before seeing my code.

@bmribler
Copy link
Contributor

bmribler commented Dec 4, 2024

Hi @bmribler, I include HDF5 as a dependency in my CMake super-build. Hence, this error occurs during the compilation of HDF5 itself before seeing my code.

Thanks!

@bmribler
Copy link
Contributor

I'm sorry, @avitase, the C++ wrapper has not been maintained for quite a while now. While you write your own wrappers, you're welcome to use the C++ wrapper code in any way if it's helpful.

@avitase I just want to let you know that the removal of the C++ wrapper has been removed from our plan for 2.0. We haven't decided on its long term support yet, but for the time being, it will continue to exist in HDF5 2.0.

@avitase
Copy link
Author

avitase commented Dec 10, 2024

@bmribler, thanks for letting me know:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - C++ C++ wrappers Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

No branches or pull requests

3 participants