Skip to content

Conversation

@zhexuany
Copy link
Contributor

@zhexuany zhexuany commented Jan 31, 2026

Summary

  • Update HDF5 library to version 2.0
  • Fix critical null pointer dereference bug in impl_tuple! macro that caused test failures
  • Fix all compiler warnings across the codebase
  • Update MSRV to 1.80.0 to enable proper cfg checking

Changes

Bug Fix: Null Pointer Dereference in impl_tuple!

The impl_tuple! macro in hdf5-types/src/h5type.rs was using undefined behavior by dereferencing a null pointer to compute field offsets:

// OLD CODE (UB)
let origin: *const Self = ptr::null();
let &(.., ref f, _) = unsafe { &*$origin };  // Dereferences null pointer!

This caused tests to fail with "null pointer dereference occurred" on recent Rust versions. Fixed by replacing with std::mem::offset_of! which is safe and stable since Rust 1.77.

Warning Fixes

  • hdf5-types: Fixed windows_dll cfg registration, lifetime elision warnings in DynValue
  • hdf5-sys: Removed unused RuntimeError struct, registered all custom cfg values
  • hdf5: Registered cfg values, fixed docrs typo, added explicit lifetimes, suppressed intentional function pointer comparison warning

MSRV Update

Updated minimum supported Rust version from 1.64.0 to 1.80.0 to enable rustc-check-cfg support for proper cfg validation.

Test plan

  • All existing tests pass
  • Build completes with no warnings
  • cargo test passes successfully

@zhexuany zhexuany force-pushed the update-hdf5-2.0 branch 2 times, most recently from 3232e3c to e9181fd Compare January 31, 2026 16:18
@codecov
Copy link

codecov bot commented Jan 31, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	.gitignore
#	Cargo.toml
#	hdf5-sys/build.rs
#	hdf5-types/src/h5type.rs
#	hdf5/src/hl/datatype.rs
zhexuany and others added 6 commits February 1, 2026 00:32
- Update repository and homepage URLs to archebase/hdf5-rs
- Add Archebase Contributors to authors list
- Update README badges and links to point to new repository
- Add Credits section to acknowledge original authors (Ivan Smirnov, Magnus Ulimoen)
- Update MSRV badge and documentation to reflect 1.92 requirement

Co-authored-by: Cursor <cursoragent@cursor.com>
Add comprehensive support for HDF5 2.0.0 including:

Build System:
- Update version parsing regex to accept HDF5 2.x versions
- Add cfg flags emission for 2.0.x versions
- Update Homebrew search to include HDF5 2.0

Versioned API Bindings:
- H5Dread_chunk2 (with new buf_size parameter)
- H5Tdecode2 (with new buf_size parameter)
- H5Iregister_type2 (hash_size parameter removed)
- Deprecated v1 APIs still available for backward compatibility

New HDF5 2.0 Types:
- H5T_COMPLEX datatype class
- Complex number predefined types (H5T_COMPLEX_IEEE_F32LE, etc.)
- bfloat16 predefined types (H5T_FLOAT_BFLOAT16LE/BE)
- FP8 predefined types (H5T_FLOAT_F8E4M3, H5T_FLOAT_F8E5M2)
- H5Tcomplex_create function binding

High-Level API:
- Add is_complex() method on Datatype (HDF5 2.0.0+)
- Handle H5T_COMPLEX class in to_descriptor()

Tests:
- Comprehensive test suite for HDF5 2.0.0 features
- Tests conditionally compiled based on HDF5 version
- Both low-level (hdf5-sys) and high-level (hdf5) tests

Documentation:
- Update README with HDF5 2.0 compatibility info
- Update CHANGELOG with new features

Co-authored-by: Cursor <cursoragent@cursor.com>
- Update hdf5-src submodule to HDF5 2.0.0 release
- Fix build.rs to set CMAKE_DEBUG_POSTFIX for HDF5 2.0 compatibility
- Update file driver bindings for HDF5 2.0 (uses global variables instead
  of init functions)
- Update high-level globals.rs to handle both pre-2.0 and 2.0+ file driver
  initialization patterns
- Fix test_get_member_names to sort results (iteration order changed in 2.0)
- Remove unnecessary unsafe blocks in HDF5 2.0 tests
- Update README and CHANGELOG to reflect bundled HDF5 2.0.0

The bundled HDF5 is now version 2.0.0, enabling all HDF5 2.0 features
including complex number datatypes, bfloat16, and FP8 types when using
static builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@zhexuany zhexuany merged commit 6d2c748 into main Jan 31, 2026
10 checks passed
@zhexuany zhexuany deleted the update-hdf5-2.0 branch January 31, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant