question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeError when writing to /dev/null

See original GitHub issue

This error occur in my unit tests, where I write data to /dev/null to throw it away. It only happens when writing empty datasets. Testcase:

import h5py

with h5py.File("/dev/null", "w") as f:
    f.create_dataset("foo", data=[])
    f.create_dataset("bar", data=[])

Output:

Traceback (most recent call last):
  File "h5py-dev-null.py", line 5, in <module>
    f.create_dataset("bar", data=[])
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/chn/env/lib/python3.8/site-packages/h5py/_hl/files.py", line 475, in __exit__
    self.close()
  File "/home/chn/env/lib/python3.8/site-packages/h5py/_hl/files.py", line 457, in close
    h5i.dec_ref(id_)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5i.pyx", line 153, in h5py.h5i.dec_ref
RuntimeError: Can't decrement id ref count (unable to extend file properly, errno = 22, error message = 'Invalid argument')
Segmentation fault

The expected result is either to work correctly or fail with OSError or equivalent. Versions:

Ubuntu 20.04.1 LTS
h5py    3.1.0
HDF5    1.12.0
Python  3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0]
sys.platform    linux
sys.maxsize     9223372036854775807
numpy   1.18.3
cython (built with) 0.29.21
numpy (built against) 1.17.5
HDF5 (built against) 1.12.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kalvdanscommented, Mar 13, 2022

Finally one year later, I managed to report it upstream: https://github.com/HDFGroup/hdf5/issues/1498

1reaction
kalvdanscommented, Feb 25, 2021

That said, this should be reported upstream (either they need to fail sooner on opening the file or more gracefully on close!). As you found this can you please take care of that @kalvdans ?

Sure! Thanks a ton for pinpointing the crash - should not be hard to make a C-only reproducer now. I will post a link here when it is done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

End of record when writing to /dev/null - Stack Overflow
In our program the STDOUT of all non-root MPI processes is closed and reopened to write to /dev/null . (Except in Debug mode,...
Read more >
What happens when you write to /dev/null? What's the point?
The null device acts like a black hole. Anything written to it is discarded, and if you try to read from it you...
Read more >
1755635 – jupyter_client: cannot start manager with stdout ...
It looks like jupyter_client cannot start a manager when stdout refers to /dev/null, at least in mock. Here's a transcript from a mock ......
Read more >
38122 – "file already opened in another unit" error when ...
The following program runs without error when compiled with g77 3.4.6 on Redhat Linux: character*72 fnint data fnint /'/dev/null'/ ...
Read more >
FORTRAN runtime error: Cannot write to file opened for READ
You received this message because you are subscribed to a topic in the Google Groups "Nek5000" group. To unsubscribe from this topic, visit ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found