incron icon indicating copy to clipboard operation
incron copied to clipboard

Recursive directory create crashes incrond

Open hongkongkiwi opened this issue 9 years ago • 17 comments

When I do mkdir dir1 then mkdir dir1/dir2 it crashes incrond process and I have to manually restart it. It works fine for files, just a directory within a directory.

hongkongkiwi avatar Jul 14 '15 16:07 hongkongkiwi

I get a segmentation fault! :/

hongkongkiwi avatar Jul 14 '15 16:07 hongkongkiwi

+1 same here:

kernel: [183657.978993] traps: incrond[12084] general protection ip:411c23 sp:7ffd8bf27ef0 error:0 in incrond[400000+1e000] systemd[1]: incron.service: main process exited, code=killed, status=11/SEGV

raptwa avatar Nov 29 '15 10:11 raptwa

+1

Oct 04 17:25:35 wohn systemd-coredump[2946]: Process 2927 (incrond) of user 0 dumped core. Stack trace of thread 2927: #0 0x00000000000164ec n/a (incrond)

As I have to monitor for a specific file below an unspecific directory, this is a deal breaker for me.

Is this project under active development anymore?

MasinAD avatar Oct 04 '17 18:10 MasinAD

Same, I'm using it to detect when USB devices are automounted. Systemd logs:

● incrond.service - Inotify System Scheduler
   Loaded: loaded (/usr/lib/systemd/system/incrond.service; enabled; vendor preset: disabled)
   Active: failed (Result: core-dump) since Tue 2018-01-09 17:26:47 EST; 2s ago
  Process: 3265 ExecStart=/usr/bin/incrond (code=exited, status=0/SUCCESS)
 Main PID: 3266 (code=dumped, signal=SEGV)

Jan 09 17:26:32 azure-angel incrond[3583]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3581]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3578]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3600]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3603]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3592]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:32 azure-angel incrond[3604]: cannot exec process: Resource temporarily unavailable
Jan 09 17:26:45 azure-angel incrond[3266]: PATH (/run/media/jeffrey) FILE (Kindle) EVENT (IN_CREATE,IN_ISDIR)
Jan 09 17:26:47 azure-angel systemd[1]: incrond.service: Main process exited, code=dumped, status=11/SEGV
Jan 09 17:26:47 azure-angel systemd[1]: incrond.service: Failed with result 'core-dump'.

Jeffrey-P-McAteer avatar Jan 09 '18 22:01 Jeffrey-P-McAteer

I am getting a similar crash if I pass a folder as part of the triggered command:

[root@MiniServer awalters]# sudo systemctl status incrond
● incrond.service - Inotify System Scheduler
   Loaded: loaded (/usr/lib/systemd/system/incrond.service; enabled; vendor preset: disabled)
   Active: failed (Result: core-dump) since Fri 2018-06-22 21:21:02 PDT; 10s ago
  Process: 7188 ExecStart=/usr/bin/incrond (code=exited, status=0/SUCCESS)
 Main PID: 7189 (code=dumped, signal=SEGV)

Jun 22 20:58:33 MiniServer incrond[7189]: loading system tables
Jun 22 20:58:33 MiniServer incrond[7189]: loading user tables
Jun 22 20:58:33 MiniServer systemd[1]: Started Inotify System Scheduler.
Jun 22 20:58:33 MiniServer incrond[7189]: loading table for user root
Jun 22 20:58:33 MiniServer incrond[7189]: ready to process filesystem events
Jun 22 21:01:09 MiniServer incrond[7189]: PATH (/mnt/externalusb/AutoDownload/complete) FILE (video1.mkv) EVENT (IN_MOVED_TO)
Jun 22 21:01:09 MiniServer incrond[7189]: (root) CMD (/usr/bin/renametvseries.sh /mnt/externalusb/AutoDownload/complete/video1.mkv > /dev/null 2>&1)
Jun 22 21:21:01 MiniServer incrond[7189]: PATH (/mnt/externalusb/AutoDownload/complete) FILE (VideosFolder) EVENT (IN_CREATE,IN_ISDIR)
Jun 22 21:21:02 MiniServer systemd[1]: incrond.service: Main process exited, code=dumped, status=11/SEGV
Jun 22 21:21:02 MiniServer systemd[1]: incrond.service: Failed with result 'core-dump'.

Here is my incrontab triggering the crash. Note above that files work fine. /mnt/externalusb/AutoDownload/complete IN_CREATE,IN_MOVED_TO /usr/bin/movevideos.sh $@/$# > /dev/null 2>&1

amwalters avatar Jun 23 '18 04:06 amwalters

I just need to mkdir to make it crash

incrontab 0.5.12
debian 10.1
incrontab -l
/root/	IN_CREATE	echo "$$ $@ $# $% $&"
root@vps:~# mkdir todelete
Nov 17 19:16:46 vps740696 incrond[12204]: PATH (/root/) FILE (todelete) EVENT (IN_CREATE,IN_ISDIR)
Nov 17 19:16:46 vps740696 incrond[12204]: PATH (/root/) FILE (todelete) EVENT (IN_CREATE,IN_ISDIR)
root@vps:~# rmNov 17 19:16:47 vps740696 kernel: [1909050.680308] incrond[12204]: segfault at 55a700000001 ip 000055a75ba65441 sp 00007ffd108afb30 error 4 in incrond[55a75ba60000+15000]
Nov 17 19:16:47 vps740696 kernel: [1909050.683439] Code: 4d 85 e4 75 21 eb 50 66 90 ba 01 00 00 00 4c 89 fe 48 89 ef 88 44 24 0f e8 ac af ff ff 48 83 c3 01 4c 39 e3 74 31 49 8b 45 00 <0f> b6 04 18 3c 20 0f 84 13 01 00 00 3c 5c 75 cf ba 02 00 00 00 48
Nov 17 19:16:47 vps740696 kernel: [1909050.680308] incrond[12204]: segfault at 55a700000001 ip 000055a75ba65441 sp 00007ffd108afb30 error 4 in incrond[55a75ba60000+15000]
Nov 17 19:16:47 vps740696 kernel: [1909050.683439] Code: 4d 85 e4 75 21 eb 50 66 90 ba 01 00 00 00 4c 89 fe 48 89 ef 88 44 24 0f e8 ac af ff ff 48 83 c3 01 4c 39 e3 74 31 49 8b 45 00 <0f> b6 04 18 3c 20 0f 84 13 01 00 00 3c 5c 75 cf ba 02 00 00 00 48
Nov 17 19:16:47 vps740696 systemd[1]: incron.service: Main process exited, code=killed, status=11/SEGV
Nov 17 19:16:47 vps740696 systemd[1]: incron.service: Failed with result 'signal'.
Nov 17 19:16:47 vps740696 systemd[1]: incron.service: Main process exited, code=killed, status=11/SEGV
Nov 17 19:16:47 vps740696 systemd[1]: incron.service: Failed with result 'signal'.
dir Nov 17 19:17:01 vps740696 CRON[12219]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Nov 17 19:17:01 vps740696 CRON[12219]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

Kassouma avatar Nov 17 '19 18:11 Kassouma

I just need to mkdir to make it crash

I have the same problem with this incron version under Gentoo Linux. Is this project sill alive?

McOrvas avatar Feb 02 '20 14:02 McOrvas

I experienced the same issue on Gentoo Linux, and did some cursory investigation. In UserTable::OnEvent, it seems that certain event types (including IN_CREATE) cause incrond to reload the in-memory set of inotify watches. However, that function later attempts to access watches that were flushed from memory, causing the crash.

I was able to work around this issue by saving the path from the inotify watch in a separate variable, and replacing the later accesses in that function with this variable:

diff --git i/usertable.cpp w/usertable.cpp
index 11fd04b..8ebe3fe 100644
--- i/usertable.cpp
+++ w/usertable.cpp
@@ -370,20 +370,21 @@ void UserTable::OnEvent(InotifyEvent& rEvt)
 {
   InotifyWatch* pW = rEvt.GetWatch();
   IncronTabEntry* pE = FindEntry(pW);
+  std::string pW_path = pW->GetPath();
 
   // no entry found - this shouldn't occur
   if (pE == NULL)
     return;
 
   // discard event if user has no access rights to watch path
-  if (!(m_fSysTable || MayAccess(pW->GetPath(), DONT_FOLLOW(rEvt.GetMask()))))
+  if (!(m_fSysTable || MayAccess(pW_path, DONT_FOLLOW(rEvt.GetMask()))))
     return;
     
   //#if 0
   // log output for each dir + file + event
   std::string events;
   rEvt.DumpTypes(events);
-  syslog(LOG_INFO, "PATH (%s) FILE (%s) EVENT (%s)", pW->GetPath().c_str() , IncronTabEntry::GetSafePath(rEvt.GetName()).c_str() , events.c_str());
+  syslog(LOG_INFO, "PATH (%s) FILE (%s) EVENT (%s)", pW_path.c_str() , IncronTabEntry::GetSafePath(rEvt.GetName()).c_str() , events.c_str());
   //#endif
   
   // add new watch for newly created subdirs
@@ -422,7 +423,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt)
       else {
         cmd.append(cs.substr(oldpos, pos-oldpos));
         if (cs[px] == '@') {          // base path
-          cmd.append(IncronTabEntry::GetSafePath(pW->GetPath()));
+          cmd.append(IncronTabEntry::GetSafePath(pW_path));
           oldpos = pos + 2;
         }
         else if (cs[px] == '#') {     // file name

I'm not sure what the proper solution is but this workaround prevents incrond from crashing for me on nested directory creation.

smkent avatar Feb 09 '20 02:02 smkent

I'll look for an alternative... This issue sucks a lot.im building a saas. And my platform refresh httpd config when a new setup is created (a new folder is created) however incron goes on subdirectories and crashes...

Blair2004 avatar Feb 19 '20 23:02 Blair2004

I'll look for an alternative...

What's under active development and maintained is systemd.path units. They have almost all the same features but don't crash. Internally, both use the kernel's inotify system AFAIK.

Obviously, that's no solution for all those avoiding systemd. But everyone else should check this out.

MasinAD avatar Feb 20 '20 06:02 MasinAD

I experienced the same issue on Gentoo Linux, and did some cursory investigation. In UserTable::OnEvent, it seems that certain event types (including IN_CREATE) cause incrond to reload the in-memory set of inotify watches. However, that function later attempts to access watches that were flushed from memory, causing the crash.

I was able to work around this issue by saving the path from the inotify watch in a separate variable, and replacing the later accesses in that function with this variable:

diff --git i/usertable.cpp w/usertable.cpp
index 11fd04b..8ebe3fe 100644
--- i/usertable.cpp
+++ w/usertable.cpp
@@ -370,20 +370,21 @@ void UserTable::OnEvent(InotifyEvent& rEvt)
 {
   InotifyWatch* pW = rEvt.GetWatch();
   IncronTabEntry* pE = FindEntry(pW);
+  std::string pW_path = pW->GetPath();
 
   // no entry found - this shouldn't occur
   if (pE == NULL)
     return;
 
   // discard event if user has no access rights to watch path
-  if (!(m_fSysTable || MayAccess(pW->GetPath(), DONT_FOLLOW(rEvt.GetMask()))))
+  if (!(m_fSysTable || MayAccess(pW_path, DONT_FOLLOW(rEvt.GetMask()))))
     return;
     
   //#if 0
   // log output for each dir + file + event
   std::string events;
   rEvt.DumpTypes(events);
-  syslog(LOG_INFO, "PATH (%s) FILE (%s) EVENT (%s)", pW->GetPath().c_str() , IncronTabEntry::GetSafePath(rEvt.GetName()).c_str() , events.c_str());
+  syslog(LOG_INFO, "PATH (%s) FILE (%s) EVENT (%s)", pW_path.c_str() , IncronTabEntry::GetSafePath(rEvt.GetName()).c_str() , events.c_str());
   //#endif
   
   // add new watch for newly created subdirs
@@ -422,7 +423,7 @@ void UserTable::OnEvent(InotifyEvent& rEvt)
       else {
         cmd.append(cs.substr(oldpos, pos-oldpos));
         if (cs[px] == '@') {          // base path
-          cmd.append(IncronTabEntry::GetSafePath(pW->GetPath()));
+          cmd.append(IncronTabEntry::GetSafePath(pW_path));
           oldpos = pos + 2;
         }
         else if (cs[px] == '#') {     // file name

I'm not sure what the proper solution is but this workaround prevents incrond from crashing for me on nested directory creation.

did that really solve?

where can I make the change, for me to test?

I'm using Pop-OS (Ubuntu 20.04 LTS).

in my syslog it shows this:

Jul 19 17:30:46 ramon kernel: [ 5192.417032] incrond[9775]: segfault at 7fb700000000 ip 0000563705c0aab1 sp 00007ffcbcc006d0 error 4 in incrond[563705c03000+15000]
Jul 19 17:30:46 ramon kernel: [ 5192.417037] Code: ed 75 23 eb 52 0f 1f 40 00 ba 01 00 00 00 4c 89 fe 4c 89 e7 88 44 24 2f e8 2c 91 ff ff 48 83 c3 01 4c 39 eb 74 31 48 8b 45 00 <0f> b6 04 18 3c 20 0f 84 13 01 00 00 3c 5c 75 cf ba 02 00 00 00 48
Jul 19 17:30:46 ramon systemd[1]: incron.service: Main process exited, code=dumped, status=11/SEGV
Jul 19 17:30:46 ramon systemd[1]: incron.service: Failed with result 'core-dump'.

ramonribeiro96 avatar Jul 19 '20 19:07 ramonribeiro96

hi guys, i am same problem, is incron stiil in development? This bug is a big bug... can someone investigate and solve please? I am on ubuntu server 20.04 and incron 5.12

Nikoh77 avatar Jan 03 '21 18:01 Nikoh77

I confirm this bug in my system too (Arch Linux) if rules in /var/spool/incron/*. But, when I put rules in /etc/incron.d/* it worked fine, and crash does not happen.

dkiyatkin avatar Mar 23 '21 19:03 dkiyatkin

I was able to work around this issue by saving the path from the inotify watch in a separate variable, and replacing the later accesses in that function with this variable: ... I'm not sure what the proper solution is but this workaround prevents incrond from crashing for me on nested directory creation.

Works nicely for me, on Gentoo too, with sys-process/incron-0.5.12_p20191114

Thank you very much. I submitted a bug about it https://bugs.gentoo.org/785448

Edit: In fact, I always have crashes with gentoo patched version.

novazur972 avatar Apr 24 '21 20:04 novazur972

If someone is looking for a backtrace,

# gdb /usr/sbin/incrond /var/tmp/coredumps/incrond.38754.1619309823
GNU gdb (Gentoo 10.1 vanilla) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/incrond...
Reading symbols from /usr/lib/debug//usr/sbin/incrond.debug...
[New LWP 38754]
Core was generated by `incrond -n'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055ae282b22b0 in IncronTabEntry::GetSafePath (rPath=...)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10/bits/basic_string.h:186
186           _M_data() const
(gdb) bt full
#0  0x000055ae282b22b0 in IncronTabEntry::GetSafePath (rPath=<error: Cannot access memory at address 0x55ab00000001>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10/bits/basic_string.h:186
        i = 0
        stream = {<std::basic_ostream<char, std::char_traits<char> >> = {<std::basic_ios<char, std::char_traits<char> >> = {<std::ios_base> = {
                _vptr.ios_base = 0x55ae282c9b70 <vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >+64>, static boolalpha = std::_S_boolalpha, static dec = std::_S_dec,
                static fixed = std::_S_fixed, static hex = std::_S_hex, static internal = std::_S_internal,
                static left = std::_S_left, static oct = std::_S_oct, static right = std::_S_right,
                static scientific = std::_S_scientific, static showbase = std::_S_showbase,
                static showpoint = std::_S_showpoint, static showpos = std::_S_showpos,
                static skipws = std::_S_skipws, static unitbuf = std::_S_unitbuf,
                static uppercase = std::_S_uppercase, static adjustfield = std::_S_adjustfield,
                static basefield = std::_S_basefield, static floatfield = std::_S_floatfield,
                static badbit = std::_S_badbit, static eofbit = std::_S_eofbit, static failbit = std::_S_failbit,
                static goodbit = std::_S_goodbit, static app = std::_S_app, static ate = std::_S_ate,
                static binary = std::_S_bin, static in = std::_S_in, static out = std::_S_out,
                static trunc = std::_S_trunc, static beg = std::_S_beg, static cur = std::_S_cur,
                static end = std::_S_end, _M_precision = 6, _M_width = 0, _M_flags = 4098,
                _M_exception = std::_S_goodbit, _M_streambuf_state = std::_S_goodbit, _M_callbacks = 0x0,
                _M_word_zero = {_M_pword = 0x0, _M_iword = 0}, _M_local_word = {{_M_pword = 0x0, _M_iword = 0}, {
                    _M_pword = 0x0, _M_iword = 0}, {_M_pword = 0x0, _M_iword = 0}, {_M_pword = 0x0, _M_iword = 0}, {
                    _M_pword = 0x0, _M_iword = 0}, {_M_pword = 0x0, _M_iword = 0}, {_M_pword = 0x0, _M_iword = 0}, {
                    _M_pword = 0x0, _M_iword = 0}}, _M_word_size = 8, _M_word = 0x7fffa0193620, _M_ios_locale = {
                  static none = 0, static ctype = 1, static numeric = 2, static collate = 4, static time = 8,
                  static monetary = 16, static messages = 32, static all = 63,
                  _M_impl = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>,
                  static _S_classic = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>,
                  static _S_global = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>,
                  static _S_categories = 0x7f91b3f73680 <__gnu_cxx::category_names>, static _S_once = 0,
                  static _S_twinned_facets = {0x7f91b3f82718 <std::numpunct<char>::id>,
                    0x7f91b3f825d8 <std::__cxx11::numpunct<char>::id>, 0x7f91b3f826e0 <std::collate<char>::id>,
                    0x7f91b3f825c0 <std::__cxx11::collate<char>::id>,
                    0x7f91b3f826f0 <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f825d0 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
                    0x7f91b3f82728 <std::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f825e8 <std::__cxx11::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
                    0x7f91b3f82720 <std::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>,--Type <RET> for more, q to quit, c to continue without paging--c
 0x7f91b3f825e0 <std::__cxx11::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f82738 <std::moneypunct<char, false>::id>, 0x7f91b3f825f8 <std::__cxx11::moneypunct<char, false>::id>, 0x7f91b3f82730 <std::moneypunct<char, true>::id>, 0x7f91b3f825f0 <std::__cxx11::moneypunct<char, true>::id>, 0x7f91b3f826e8 <std::messages<char>::id>, 0x7f91b3f825c8 <std::__cxx11::messages<char>::id>, 0x7f91b3f827d8 <std::numpunct<wchar_t>::id>, 0x7f91b3f82658 <std::__cxx11::numpunct<wchar_t>::id>, 0x7f91b3f827a0 <std::collate<wchar_t>::id>, 0x7f91b3f82640 <std::__cxx11::collate<wchar_t>::id>, 0x7f91b3f827b0 <std::time_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82650 <std::__cxx11::time_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827e8 <std::money_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82668 <std::__cxx11::money_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827e0 <std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82660 <std::__cxx11::money_put<wchar_t, std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827f8 <std::moneypunct<wchar_t, false>::id>, 0x7f91b3f82678 <std::__cxx11::moneypunct<wchar_t, false>::id>, 0x7f91b3f827f0 <std::moneypunct<wchar_t, true>::id>, 0x7f91b3f82670 <std::__cxx11::moneypunct<wchar_t, true>::id>, 0x7f91b3f827a8 <std::messages<wchar_t>::id>, 0x7f91b3f82648 <std::__cxx11::messages<wchar_t>::id>, 0x0, 0x0}}}, _M_tie = 0x0, _M_fill = 0 '\000', _M_fill_init = false, _M_streambuf = 0x7fffa0193578, _M_ctype = 0x7f91b3f81700 <(anonymous namespace)::ctype_c>, _M_num_put = 0x7f91b3f81690 <(anonymous namespace)::num_put_c>, _M_num_get = 0x7f91b3f816a0 <(anonymous namespace)::num_get_c>}, _vptr.basic_ostream = 0x55ae282c9b48 <vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >+24>}, _M_stringbuf = {<std::basic_streambuf<char, std::char_traits<char> >> = {_vptr.basic_streambuf = 0x55ae282c9d18 <vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >+16>, _M_in_beg = 0x0, _M_in_cur = 0x0, _M_in_end = 0x0, _M_out_beg = 0x0, _M_out_cur = 0x0, _M_out_end = 0x0, _M_buf_locale = {static none = 0, static ctype = 1, static numeric = 2, static collate = 4, static time = 8, static monetary = 16, static messages = 32, static all = 63, _M_impl = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>, static _S_classic = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>, static _S_global = 0x7f91b3f81ce0 <(anonymous namespace)::c_locale_impl>, static _S_categories = 0x7f91b3f73680 <__gnu_cxx::category_names>, static _S_once = 0, static _S_twinned_facets = {0x7f91b3f82718 <std::numpunct<char>::id>, 0x7f91b3f825d8 <std::__cxx11::numpunct<char>::id>, 0x7f91b3f826e0 <std::collate<char>::id>, 0x7f91b3f825c0 <std::__cxx11::collate<char>::id>, 0x7f91b3f826f0 <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f825d0 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f82728 <std::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f825e8 <std::__cxx11::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f82720 <std::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f825e0 <std::__cxx11::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7f91b3f82738 <std::moneypunct<char, false>::id>, 0x7f91b3f825f8 <std::__cxx11::moneypunct<char, false>::id>, 0x7f91b3f82730 <std::moneypunct<char, true>::id>, 0x7f91b3f825f0 <std::__cxx11::moneypunct<char, true>::id>, 0x7f91b3f826e8 <std::messages<char>::id>, 0x7f91b3f825c8 <std::__cxx11::messages<char>::id>, 0x7f91b3f827d8 <std::numpunct<wchar_t>::id>, 0x7f91b3f82658 <std::__cxx11::numpunct<wchar_t>::id>, 0x7f91b3f827a0 <std::collate<wchar_t>::id>, 0x7f91b3f82640 <std::__cxx11::collate<wchar_t>::id>, 0x7f91b3f827b0 <std::time_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82650 <std::__cxx11::time_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827e8 <std::money_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82668 <std::__cxx11::money_get<wchar_t, std::istreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827e0 <std::money_put<wchar_t, std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f82660 <std::__cxx11::money_put<wchar_t, std::ostreambuf_iterator<wchar_t, std::char_traits<wchar_t> > >::id>, 0x7f91b3f827f8 <std::moneypunct<wchar_t, false>::id>, 0x7f91b3f82678 <std::__cxx11::moneypunct<wchar_t, false>::id>, 0x7f91b3f827f0 <std::moneypunct<wchar_t, true>::id>, 0x7f91b3f82670 <std::__cxx11::moneypunct<wchar_t, true>::id>, 0x7f91b3f827a8 <std::messages<wchar_t>::id>, 0x7f91b3f82648 <std::__cxx11::messages<wchar_t>::id>, 0x0, 0x0}}}, _M_mode = std::_S_out, _M_string = ""}}
        len = 94206516241848
#1  0x000055ae282b99fd in UserTable::OnEvent (this=0x55ae29ef2470, rEvt=...) at inotify-cxx.h:424
        px = 44
        pW = 0x55ae29ee61e0
        pE = 0x55ae29ee92e0
        events = "IN_MOVED_TO,IN_ISDIR"
        cmd = " logger -t incron-test \"bug785448 trigger: "
        cs = " logger -t incron-test \"bug785448 trigger: $@/$#\""
        pos = 43
        oldpos = 0
        len = 49
        pid = <optimized out>
#2  0x000055ae282b9d4c in EventDispatcher::ProcessEvents (this=this@entry=0x7fffa0193930) at usertable.cpp:110
        pIn = 0x55ae29ef2478
        it = {first = 4, second = 0x55ae29ee6450}
        i = 2
        pipe = <optimized out>
        evt = {m_uMask = 1073741952, m_uCookie = 26057, m_name = "foo", m_pWatch = 0x55ae29ee61e0}
#3  0x000055ae282af362 in main (argc=<optimized out>, argv=0x7fffa0193990) at icd-main.cpp:469
        res = <optimized out>
        wm = 10184
        in = {m_fd = 6, m_watches = std::map with 2 elements = {[1] = 0x7fffa0193a90, [2] = 0x7fffa0193ad0}, m_paths = std::map with 2 elements = {["/etc/incron.d"] = 0x7fffa0193a90, ["/var/spool/incron"] = 0x7fffa0193ad0}, m_buf = '\000' <repeats 28400 times>..., m_events = std::deque with 0 elements}
        stw = {m_path = "/etc/incron.d", m_uMask = 10184, m_wd = 1, m_pInotify = 0x7fffa0193b10, m_fEnabled = true}
        utw = {m_path = "/var/spool/incron", m_uMask = 10184, m_wd = 2, m_pInotify = 0x7fffa0193b10, m_fEnabled = true}
        ed = {m_iPipeFd = 4, m_iMgmtFd = 6, m_pIn = 0x7fffa0193b10, m_pSys = 0x7fffa0193a90, m_pUser = 0x7fffa0193ad0, m_maps = std::map with 1 element = {[8] = 0x55ae29ef2470}, m_size = 3, m_pPoll = 0x55ae29ee6500}
        cfg = "/etc/incron.conf"
        lckdir = "/var/run"
        lckfile = "incrond"
        app = {m_path = "/var/run/incrond.pid", m_fLocked = true}
        ret = 0
        sysBase = "/etc/incron.d"
        userBase = "/var/spool/incron"

So the trigger is really accessing the path $@.

And the reload mentioned by @smkent happens in

https://github.com/ar-/incron/blob/6f4c9a222a6bd802f25b1d266442222e886eee1e/usertable.cpp#L389-L408

so this code could either be moved to the end of the function (in which case the action would fire before new watchers for the new folder(s) are created) or like @smkent proposed, the value could be stored in a temporary variable which will be still available later when the old watch InotifyWatch object was already disposed.

Whissi avatar Apr 25 '21 00:04 Whissi

@Whissi can confirm that i don't get a segmentation fault as soon i remove the $@ parameter.

UtechtDustin avatar Oct 01 '21 12:10 UtechtDustin

I confirm this bug in my system too (Arch Linux) if rules in /var/spool/incron/*. But, when I put rules in /etc/incron.d/* it worked fine, and crash does not happen.

This works for mi too!!

hbustos2 avatar May 03 '22 16:05 hbustos2