Extract stats into their own file#129
Conversation
|
I'll take a look later, only just very briefly looked at it. Is this only a refactoring? Any functional changes to point out? |
|
What is the scientific study also? I'm trying to learn a little more about what the varying users of this are using the tools for 😄 |
|
Thanks for making it easy to review, new unique lines: |
|
Hi, thanks for accepting the Pullrequest. We don't use inotify directly, it rather is an evaluation target for an automated refactoring approach we are developing. We want to extract "modules" based on keyphrases, in this case "stats". |
|
Could you show the code/script/designs? I guess it worked out ok here. |
|
This made libinotifytools' |
|
Thanks so much for reporting @NiLuJe ! Two things needed here, I think. Add a statically linked build to our build script and remove the code duplication. |
|
Would you mind adding the exact way you build to: build_and_test.sh and opening a PR? |
Running inotifywait 3.22.1.0 on Ubuntu 22.04, I observed a bug
apparently due to a bad file descriptor:
$ inotifywait -e modify foo
Setting up watches.
Couldn't watch foo: Bad file descriptor
I could also reproduce with the master branch. Investigating further, it
appears that inotifytools_init() in inotifytools.c exits immediately
after entry, because the global variable "init" is non-null, even though
we just called it at the beginning of inotifywait.c's main(), and the
global variable is supposed to be initialised at 0.
Bisecting showed that this variable used to be static, but was changed
at some point to non-static to share it with stats.c, and this is where
the bug fist occurs. As far as I understand, the symbol conflicts with
the init() function from the program's entry point [0]. When entering
inotifytools_init(), it seems that the value for that function is picked
up and compared to 0, found non-null, and the initialization function
exits, leaving inotify_fd uninitialized (-1) and a bad file descriptor.
Renaming the variable to something other than "init" is enough to fix
the bug.
$ ./src/inotifywait -e modify foo
Setting up watches.
Watches established
<waits>
[0] https://www.geeksforgeeks.org/executing-main-in-c-behind-the-scene/
Fixes: dd59c53 ("Extract stats into their own file (inotify-tools#129)")
Running inotifywait 3.22.1.0 on Ubuntu 22.04, I observed a bug
apparently due to a bad file descriptor:
$ inotifywait -e modify foo
Setting up watches.
Couldn't watch foo: Bad file descriptor
I could also reproduce with the master branch. Investigating further, it
appears that inotifytools_init() in inotifytools.c exits immediately
after entry, because the global variable "init" is non-null, even though
we just called it at the beginning of inotifywait.c's main(), and the
global variable is supposed to be initialised at 0.
Bisecting showed that this variable used to be static, but was changed
at some point to non-static to share it with stats.c, and this is where
the bug fist occurs. As far as I understand, the symbol conflicts with
the init() function from the program's entry point [0]. When entering
inotifytools_init(), it seems that the value for that function is picked
up and compared to 0, found non-null, and the initialization function
exits, leaving inotify_fd uninitialized (-1) and a bad file descriptor.
Renaming the variable to something other than "init" is enough to fix
the bug.
$ ./src/inotifywait -e modify foo
Setting up watches.
Watches established
<waits>
[0] https://www.geeksforgeeks.org/executing-main-in-c-behind-the-scene/
Fixes: dd59c53 ("Extract stats into their own file (#129)")
Running inotifywait 3.22.1.0 on Ubuntu 22.04, I observed a bug
apparently due to a bad file descriptor:
$ inotifywait -e modify foo
Setting up watches.
Couldn't watch foo: Bad file descriptor
I could also reproduce with the master branch. Investigating further, it
appears that inotifytools_init() in inotifytools.c exits immediately
after entry, because the global variable "init" is non-null, even though
we just called it at the beginning of inotifywait.c's main(), and the
global variable is supposed to be initialised at 0.
Bisecting showed that this variable used to be static, but was changed
at some point to non-static to share it with stats.c, and this is where
the bug fist occurs. As far as I understand, the symbol conflicts with
the init() function from the program's entry point [0]. When entering
inotifytools_init(), it seems that the value for that function is picked
up and compared to 0, found non-null, and the initialization function
exits, leaving inotify_fd uninitialized (-1) and a bad file descriptor.
Renaming the variable to something other than "init" is enough to fix
the bug.
$ ./src/inotifywait -e modify foo
Setting up watches.
Watches established
<waits>
[0] https://www.geeksforgeeks.org/executing-main-in-c-behind-the-scene/
Fixes: dd59c53 ("Extract stats into their own file (inotify-tools#129)")
#170) Running inotifywait 3.22.1.0 on Ubuntu 22.04, I observed a bug apparently due to a bad file descriptor: $ inotifywait -e modify foo Setting up watches. Couldn't watch foo: Bad file descriptor I could also reproduce with the master branch. Investigating further, it appears that inotifytools_init() in inotifytools.c exits immediately after entry, because the global variable "init" is non-null, even though we just called it at the beginning of inotifywait.c's main(), and the global variable is supposed to be initialised at 0. Bisecting showed that this variable used to be static, but was changed at some point to non-static to share it with stats.c, and this is where the bug fist occurs. As far as I understand, the symbol conflicts with the init() function from the program's entry point [0]. When entering inotifytools_init(), it seems that the value for that function is picked up and compared to 0, found non-null, and the initialization function exits, leaving inotify_fd uninitialized (-1) and a bad file descriptor. Renaming the variable to something other than "init" is enough to fix the bug. $ ./src/inotifywait -e modify foo Setting up watches. Watches established <waits> [0] https://www.geeksforgeeks.org/executing-main-in-c-behind-the-scene/ Fixes: dd59c53 ("Extract stats into their own file (#129)")
Hi,
we've extracted some parts concerning the file access event stats into their own file during the course of a scientific study. We want to check with whether this extraction seems sensible for you.