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

Windows fatal exception with libver = 'latest' and group.copy #2413

Open
ndeipenbrock opened this issue Apr 22, 2024 · 3 comments
Open

Windows fatal exception with libver = 'latest' and group.copy #2413

ndeipenbrock opened this issue Apr 22, 2024 · 3 comments

Comments

@ndeipenbrock
Copy link

When I create a dataset with the libver= 'latest', the terminal crashes with the "group.copy" command.
In the following example program, the kernel will crash.

libversion = ('latest', 'earliest')
arr1 = np.random.randn(1000)
with h5py.File('testfile.h5', 'w', libver=libversion[0]) as f:
    g = f.create_group('Base_Group2', track_order=True)
    dset = g.create_dataset('dataset', (1000,))
    dset[:] = arr1
    for i in range(10):
        dset.attrs["int" + str(i)] = int(10)
    for i in range(10):
        dset.attrs["string"+str(i)] = str("text")

with h5py.File('Copy.hdf5', 'w') as f:
    g = f.create_group("Base_Group")
    with h5py.File('testfile.h5', 'r') as f2:
        g.copy(f2["Base_Group2"], g)

Out: Windows fatal exception: access violation
Main thread:
Current thread 0x000005dc (most recent call first):
Kernel is restarted

With the libver= 'earliest' the copy command works as intended. However, I needed the function swmr_mode,
so I am dependent on the libversion latest.
I found out that the error is caused by variables string lengths in the attributes.

A workaround is to fixed the string length.

text = "text"
string_length = len(text)
utf8_type = h5py.string_dtype('utf-8', string_length)

Can someone tell me if this is a bug or if I had made a mistake somewhere?

Config of the System:
Windows 10

h5py.version.info
3.11.0\nHDF5    1.14.2\nPython  3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12)
[MSC v.1935 64 bit (AMD64)]\nsys.platform    win32\nsys.maxsize     9223372036854775807\nnumpy
1.26.4\ncython (built with) 3.0.10\nnumpy (built against) 2.0.0rc1\nHDF5 (built against) 1.14.2\n'
@takluyver
Copy link
Member

It's a bug. Even if you're doing something wrong (which I don't think you are), mistakes in Python code should always give you a Python exception, not a hard crash like that.

It's very likely to be a bug in HDF5 itself, because the Group.copy() method in h5py is basically just wrapping the HDF5 H5Ocopy function. It might be the same as, or related to, this issue, which also involves crashes while copying objects with attributes. Or it might be a separate problem.

@aragilar
Copy link
Member

@ndeipenbrock Is this using conda, pip or something else to install h5py?

@ndeipenbrock
Copy link
Author

@aragilar I use pip to install h5py. The error message only appears in Spyder, not when I run the program via the CMD/Python Console. No error message is displayed there. Nevertheless, the copy command is also not executed.

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

No branches or pull requests

3 participants