Running test-bus on Linux fails with 'dbus-daemon - Cannot initialize inotify'
To see if the problem reported at #360 (closed) was related to the cmake build system, the same test was compiled and run on Linux (openSUSE 15.2, gcc 7.5)
mkdir ~/src
cd ~/src
git clone https://gitlab.freedesktop.org/dbus/dbus.git
mkdir build-cmake
cd build-cmake
cmake ../dbus
make
ctest -R test-bus$ -VV
The following error occurred:
9: ok 6 - signals
9: # signals test took 1 seconds
9: ok 7 - signals did not leak memory
9: # Running test: activation-service-reload
9: dbus-daemon[28279]: Cannot initialize inotify
9: /home/xxx/src/dbus-cmake-build/lib/libdbus-1.so.3(_dbus_print_backtrace+0x1f) [0x7f0da73252cf]
9: /home/xxx/src/dbus-cmake-build/lib/libdbus-1.so.3(_dbus_abort+0xd) [0x7f0da731e2c9]
9: /home/xxx/src/dbus-cmake-build/lib/libdbus-1.so.3(_dbus_warn+0xf2) [0x7f0da730c292]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus() [0x441fcf]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(bus_set_watched_dirs+0x1c) [0x442100]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus() [0x416976]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(bus_context_new+0x7b6) [0x41713f]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(bus_context_new_test+0x107) [0x441886]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus() [0x415235]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(bus_activation_service_reload_test+0xdd) [0x41551d]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(_dbus_test_main+0x252) [0x443155]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(main+0x3c) [0x41050a]
9: /lib64/libc.so.6(__libc_start_main+0xea) [0x7f0da685534a]
9: /home/xxx/src/dbus-cmake-build/bin/test-bus(_start+0x2a) [0x4103fa]
In the case of a temporary problem caused by too many open files, the message can be reproduced by a previous call to sudo sh -c "echo 0 > /proc/sys/fs/inotify/max_user_instances"
, but this returns -1
as the return value of inotify_initx()
rather than the 0
value under discussion.
A different approach to reproduce is to run:
$ gdb --args bin/test-bus test/data
(gdb) b dir-watch-inotify.c:225
r
Breakpoint 1, _init_inotify (context=0x6824c0) at /home/ralf.habacker/src/dbus/bus/dir-watch-inotify.c:225
225 if (inotify_fd == -1)
(gdb) call (int)close(0)
$1 = 0
(gdb) c
dbus-daemon[9502]: Cannot initialize inotify
Breakpoint 1, _init_inotify (context=0x683880) at /home/ralf.habacker/src/dbus/bus/dir-watch-inotify.c:225
225 if (inotify_fd == -1)
(gdb) p inotify_fd
$3 = 0
The same behavior can be reproduced with dbus-daemon
.
The problem with the message dbus-daemon[11508]: Cannot initialize inotify: Too many open files
also occurred after a package update of the Linux system (openSUSE Leap) that required a reboot, but the reboot had not yet been performed.