Skip to content

gstdio: fail assertion in g_close() for invalid file descriptor (EBADF)

Thomas Haller requested to merge th/g-close-ebadf into main

An application must keep track of the file descriptors that it has. Closing an invalid, non-negative file descriptor is usually a bug, because it indicates somebody messed up the tracking.

On a single threaded application it may be fine, but EBADF is always a bug in a multi threaded application because another thread might race reusing the bad file descriptor. With GDBus and other glib API, it is very common that your application has multiple threads running and this is in fact a bug.

The assertion failure does not necessarily indicate that the bug is in the caller. It could have been another part of the application that wrongly closed the file descriptor.

Merge request reports