Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Use H5allocate_memory/H5free_memory for buffers exchanged with HDF5 in all filters

Abierto
#291 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, cmake
Área
data

Línea de trabajo

Start with the ZSTD fix in #290 as the pattern, then open the per-filter sources listed in the checklist (for example BLOSC/src/H5Zblosc.c and BZIP2/src/H5Zbzip2.c). Swap each malloc/realloc/free on a buffer crossing the callback boundary for H5allocate_memory/H5resize_memory/H5free_memory, and leave filter-private scratch buffers alone. The SZ and MAFISC sites need the most judgment because their library-returned buffers must be copied first. Done means every checklist item is converted and each filter has a passing round-trip test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Background

#289 showed that the ZSTD filter crashed on Windows because it freed the buffer HDF5 passed in (*buf) with the plugin's CRT free(), and returned a buffer from the plugin's CRT malloc() for HDF5 to free. The plugin DLL and hdf5.dll can link different CRTs, so the allocator and deallocator must match. #290 fixes ZSTD.

The rule: any buffer that crosses the filter callback boundary must use H5allocate_memory() / H5resize_memory() / H5free_memory(). That means the old *buf being released and the new buffer assigned to *buf, including the error-path free of that new buffer. Buffers private to the filter (scratch space, library-internal state) can stay on malloc/free.

Line numbers are against master at bafec5a3.

Filters to change

  • BLOSC BLOSC/src/H5Zblosc.c: malloc at 297, 332; free(outbuf) at 317, 354; free(*buf) at 347
  • BLOSC2 BLOSC2/src/H5Zblosc2.c: malloc at 619, 656; free(*buf) at 684; free(outbuf) at 692. The free(chunk) at 675 is internal; check needs_free and leave it unless the chunk comes from HDF5.
  • BSHUF BSHUF/src/H5Zbshuf.c: malloc at 300; free(out_buf) at 358; free(*buf) at 362. The malloc/free in bitshuffle.c and bitshuffle_core.c are scratch buffers and stay.
  • BZIP2 BZIP2/src/H5Zbzip2.c: malloc at 155, 232; realloc at 188 (use H5resize_memory); free(*buf) at 249; free(outbuf) at 256. The comment at 161 refers to bzip2's internal allocator and stays.
  • JPEG JPEG/src/H5Zjpeg.c: malloc at 189, 333; free(*buf) at 348; free(out_buf) at 357. Check whether outData (346, 355) is library-owned.
  • LZ4 LZ4/src/H5Zlz4.c: malloc at 155, 243; free(*buf) at 187, 285; free(outBuf) at 293, 298
  • LZF LZF/src/H5Zlzf.c: malloc at 253, 282; free(outbuf) at 276, 318; free(*buf) at 311
  • ZFP ZFP/H5Z-ZFP/src/H5Zzfp.c: malloc at 607, 674; free(*buf) at 649, 697; free(newbuf) at 708. The ctrls_p allocation in H5Zzfp_props.c is not passed to HDF5 and stays.
  • SZ (community) community/SZ/src/H5Zszf.c: free(*buf) at 583-786, about 25 sites. SZ_compress* and SZ_decompress return buffers allocated inside the SZ library with malloc. Those results need to be copied into an H5allocate_memory() buffer before they are assigned to *buf, then freed with the SZ library's allocator. This one is more than a mechanical swap.
  • MAFISC (community) community/MAFISC/src/mafisc.c: free(*buffer) at 762 with buffer2 (malloc at 730) assigned to *buffer. Check the compress path around 829-912 (buffer1, buffer2, curBuffer, bestBuffer) for whichever buffer is returned to HDF5.
  • ZSTD ZSTD/src/H5Zzstd.c: fixed in #290

No change needed

These filters modify *buf in place and never replace it.

  • BITGROOM: mss_val at H5Zbitgroom.c:393 is internal.
  • GRANULAR_BITROUND: mss_val at H5Zgranularbr.c:388 is internal.
  • BITROUND

Verification

Each filter should get a round-trip test, plus a check under an allocator-aware tool (ASan or the MSVC debug heap) where possible. Windows with mismatched CRTs is the case that fails.

Lenguaje dominante
CMake
Estrellas
21
Forks
27
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de HDFGroup/hdf5_plugins

Todos los issues de HDFGroup/hdf5_plugins

Issues similares

Más issues de Data Engineering

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.