incron
incron copied to clipboard
Segfault in 0.5.12 when monitoring multiple directory create
When doing a multiple directory create in a monitored path, whether recursive monitoring is enabled or not, incron-0.5.12 fails to properly trigger events for all the new folders, and occasionally segfaults. Tested with incron-0.5.12 compiled on RHEL5 and CentOS7.
Typical create command: mkdir /u01/vsftp/testdir_00{1..9}
Sample error from /var/log/messages: RHEL5: Mar 17 11:55:51 indy kernel: incrond[16257]: segfault at fffffffffffffffe rip 00000000004089ec rsp 00007fff16d90240 error 4
CentOS7: Mar 17 15:09:47 rudi kernel: traps: incrond[8998] general protection ip:4126b0 sp:7fff01f04308 error:0 in incrond[400000+1d000]
This behavior also appeared when copying or moving a directory tree into a (recursively) monitored path.
I can provide more detail on the environment and testing done if needed. I don't have the skills needed to trace the source of the problem in the code, so I'll leave that to your capable hands.
I could not reproduce this so far. Can you tell me which attribute you are observing? It is a read or write access? Also are you obersiv "LOTS" of files? Is it 10, 100, 100000 ... files? Since you say it happens sporadically, my first would be the thread limit.
I think I've bumped into this issue while working on #18. The segfault I saw was inside a m_map.find() call in UserTable::FindEntry, which could be related to a race condition with the Dispose()/Load() cycle. Since Dispose() removes items from the maps, a new event that gets triggered before Dispose(), but actually processed after it, gets its m_map pulled from under its feet, so to speak. However, I didn't dig deep enough to confirm this.
I am seeing the same thing using the incron build from the PPA on Ubuntu 14.04. This is my incrontab:
/home/calle/Documents/scan IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/$# /home/calle/Documents/scan/versicherung IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/versicherung_$# /home/calle/Documents/scan/reisekosten IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/reisekosten/$# /home/calle/Documents/scan/wohnung IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/wohnung/$# /home/calle/Documents/scan/other IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/other/$# /home/calle/Documents/scan/steuer IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/steuer/$# /home/calle/Documents/scan/job IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/job/$# /home/calle/Documents/scan/extra IN_CLOSE_WRITE,recursive=false /home/calle/bin/pdfocr-incoming.fish $@/$# /home/calle/Documents/scanned/extra/$# /home/calle/Documents/scanned/ IN_CREATE,IN_DELETE,IN_CLOSE_WRITE,IN_MOVE /usr/bin/flock /home/calle/.update-document-index.lock /home/calle/bin/update-document-index $% $@/$#
The interesting part seems to be the last line. So far every time I attempted to create a directory within the monitored directory, incron dies and i find this in dmesg:
incrond[12741]: segfault at 7f59ffffffe9 ip 00000000004079f5 sp 00007fff8262e470 error 4 in incrond[400000+1e000]
I'm also having this same problem on the latest ubuntu ppa
This is still alive but looks like it ties to passing arguments to the underlying script and being triggered by a directory: https://bugzilla.redhat.com/show_bug.cgi?id=1786640
still a bug in CentOS 8 on 2020.
Just happened to me as I was unzipping a file into a directory monitored by incron. I’m using Ubuntu 20.04. incron successfully logged the first event from the unzipping, which was of type “EVENT (IN_CREATE,IN_ISDIR),” and then immediately after that it received a SIGSEGV.
My incrontab:
any update on this?
I have the same problem. The problem seems related to the wildcards used in the command specification. If I only use $#, then it works fine, but if I use both $@
and $#
, then I trigger the segfault if I create folders with long name.
As demonstrated here:
incrontab:
/data/test IN_CREATE,recursive=false /bin/true $#
Jun 16 18:10:55 test-host incrond[2053892]: table for user ubuntu changed, reloading
Jun 16 18:11:02 test-host incrond[2053892]: PATH (/data/test) FILE (wfwfw) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:11:03 test-host incrond[2053892]: (ubuntu) CMD (/bin/true wfwfw)
Jun 16 18:11:04 test-host incrond[2053892]: PATH (/data/test) FILE (fwefkmlwkfmw) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:11:05 test-host incrond[2053892]: (ubuntu) CMD (/bin/true fwefkmlwkfmw)
Jun 16 18:11:07 test-host incrond[2053892]: PATH (/data/test) FILE (lkmflwkmflekwmflkmweflmwfklw) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:11:08 test-host incrond[2053892]: (ubuntu) CMD (/bin/true lkmflwkmflekwmflkmweflmwfklw)
Jun 16 18:11:10 test-host incrond[2053892]: PATH (/data/test) FILE (lkmflkwmflwkmflkwmflwmflw) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:11:11 test-host incrond[2053892]: (ubuntu) CMD (/bin/true lkmflkwmflwkmflkwmflwmflw)
Jun 16 18:11:15 test-host incrond[2053892]: PATH (/data/test) FILE (lkfmwlkfmwlkfmlwkmflwkmflwmkflwmfw) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:11:16 test-host incrond[2053892]: (ubuntu) CMD (/bin/true lkfmwlkfmwlkfmlwkmflwkmflwmkflwmfw)
updated to:
/data/test IN_CREATE,recursive=false /bin/true "$@/$#"
Jun 16 18:15:10 test-host incrond[2057995]: loading table for user ubuntu
Jun 16 18:15:10 test-host incrond[2057995]: ready to process filesystem events
Jun 16 18:16:05 test-host incrond[2057995]: PATH (/data/test) FILE (shorterthan16cs) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:16:06 test-host incrond[2057995]: (ubuntu) CMD (/bin/true "/data/test/shorterthan16cs")
Jun 16 18:16:17 test-host incrond[2057995]: PATH (/data/test) FILE (longerthan16chars) EVENT (IN_CREATE,IN_ISDIR)
Jun 16 18:16:18 test-host kernel: [15844994.384819] incrond[2057995]: segfault at 55b400000001 ip 000055b182e23ab1 sp 00007ffe789f3f10 error 4 in incrond[55b182e1c000+15000]
Jun 16 18:16:18 test-host systemd[1]: incron.service: Main process exited, code=dumped, status=11/SEGV
Jun 16 18:16:18 test-host systemd[1]: incron.service: Failed with result 'core-dump'.
It also seems like that the argument to the command is very picky on what you provide. If I provide it without quotes, just $@/$#
then it segfaults more frequently - even though the new file/folder is less than 16 characters. So there's definitely an issue here.