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

Segmentation fault when opening unseekable file #1498

Closed
kalvdans opened this issue Mar 13, 2022 · 2 comments
Closed

Segmentation fault when opening unseekable file #1498

kalvdans opened this issue Mar 13, 2022 · 2 comments
Assignees
Labels
Component - C Library Core C library issues (usually in the src directory) Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub Type - Security Security issues, including library crashers and memory leaks
Milestone

Comments

@kalvdans
Copy link

I tried to use /dev/null in a unit test (since I'm not interested in the result) but the library crashes hard. This is a minimal test case:

#include <H5Fpublic.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
    hid_t fileobject = H5Fcreate("/dev/null", H5F_ACC_TRUNC, 0, 0);
    return H5Fclose(fileobject);
}

The output when running is:

$ gcc -Wall h5py-bug-1775.c -I /usr/include/hdf5/serial -l hdf5_serial && ./a.out 
HDF5-DIAG: Error detected in HDF5 (1.10.4) thread 139699578592128:
  #000: ../../../src/H5F.c line 668 in H5Fclose(): closing file ID failed
    major: File accessibilty
    minor: Unable to close file
  #001: ../../../src/H5Fint.c line 2047 in H5F__close(): decrementing file ID failed
    major: File accessibilty
    minor: Unable to decrement reference count
  #002: ../../../src/H5I.c line 1309 in H5I_dec_app_ref(): can't decrement ID ref count
    major: Object atom
    minor: Unable to decrement reference count
  #003: ../../../src/H5Fint.c line 2105 in H5F__close_cb(): can't close file
    major: File accessibilty
    minor: Unable to close file
  #004: ../../../src/H5Fint.c line 2276 in H5F_try_close(): problems closing file
    major: File accessibilty
    minor: Unable to close file
  #005: ../../../src/H5Fint.c line 1130 in H5F__dest(): unable to flush cached data (phase 2)
    major: File accessibilty
    minor: Unable to flush data from cache
  #006: ../../../src/H5Fint.c line 1896 in H5F__flush_phase2(): low level truncate failed
    major: File accessibilty
    minor: Write failed
  #007: ../../../src/H5FD.c line 1581 in H5FD_truncate(): driver truncate request failed
    major: Virtual File Layer
    minor: Can't update object
  #008: ../../../src/H5FDsec2.c line 892 in H5FD_sec2_truncate(): unable to extend file properly, errno = 22, error message = 'Invalid argument'
    major: Low-level I/O
    minor: Seek failed
Segmentation fault

I understand that hdf5 library wants to seek in the file, but it should fail gracefully. My version:

$ dpkg -l | grep libhdf5-dev
ii  libhdf5-dev                                   1.10.4+repack-11ubuntu1                                         amd64        Hierarchical Data Format 5 (HDF5) - development files - serial version
@derobins
Copy link
Member

For something that looks like a simple fix, addressing this is probably going to involve tidying a rat's nest of file cleanup code.

For the record, the "/dev/nul" equivalent on Windows is "NUL"

@derobins derobins added Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Component - C Library Core C library issues (usually in the src directory) Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub labels May 4, 2023
@mattjala mattjala added this to the 1.14.5 milestone Jan 19, 2024
@derobins derobins added the Type - Security Security issues, including library crashers and memory leaks label Jun 25, 2024
@mattjala
Copy link
Contributor

This issue is fixed in later major releases of the library (1.12/1.14). We no longer support 1.10, so I'm closing this issue. #4720 adds a regression test to make sure this doesn't reoccur moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - C Library Core C library issues (usually in the src directory) Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub Type - Security Security issues, including library crashers and memory leaks
Projects
None yet
Development

No branches or pull requests

3 participants