Memleak in filestat
Libsanitizer report memleak in filestat
$ src/filenotify -c test.config
Sat Mar 21 21:06:20 : INFO : Config : logfile=/tmp/extraarg-test.sh.log
Sat Mar 21 21:06:20 : INFO : Config : loglevel=DEBUG
Sat Mar 21 21:06:20 : INFO : Config : watch_directory.0=/tmp/test-extraarg-test.sh-1
Sat Mar 21 21:06:20 : INFO : Config : watch_directory.0.extra_post_data=metadata=test1
Sat Mar 21 21:06:20 : INFO : Config : watch_directory.1=/tmp/test-extraarg-test.sh-2
Sat Mar 21 21:06:20 : INFO : Config : watch_directory.1.extra_post_data=metadata=test2
Sat Mar 21 21:06:20 : INFO : Config : plugins_dir=src/plugins/.libs/
Sat Mar 21 21:06:20 : INFO : Config : clamav.dbdir=/var/lib/clamav
Sat Mar 21 21:06:20 : INFO : Config : plugins.clamav=libplg_clamav.so
Sat Mar 21 21:06:20 : INFO : Config : plugins.log=libplg_notify_log.so
Sat Mar 21 21:06:20 : INFO : Config : plugins.exec=libplg_notify_exec.so
Sat Mar 21 21:06:20 : INFO : Config : exec.cmd=echo "{{ dirname }},{{ filename }},{{ extra_post_data }},{{ event_type_int }}" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:20 : INFO : Chargement du plugins : src/plugins/.libs/libplg_notify_exec.so
Sat Mar 21 21:06:20 : DEBUG : Init plugins : plg_notify_exec(exec)
Sat Mar 21 21:06:20 : INFO : Chargement du plugins : src/plugins/.libs/libplg_notify_log.so
Sat Mar 21 21:06:20 : DEBUG : Init plugins : plg_notify_log(log)
Sat Mar 21 21:06:20 : INFO : Chargement du plugins : src/plugins/.libs/libplg_clamav.so
Sat Mar 21 21:06:38 : INFO : *** Welcome in filenotifier (inotify) ***
Sat Mar 21 21:06:38 : DEBUG : inotify descriptor=1 for directory /tmp/test-extraarg-test.sh-1/
Sat Mar 21 21:06:38 : INFO : Presence initiale du fichier : /tmp/test-extraarg-test.sh-1/toto
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:38 : INFO : plg_clamav(clamav) : No virus detected
Sat Mar 21 21:06:38 : INFO : [log][IN_CLOSE_WRITE] 0 : /tmp/test-extraarg-test.sh-1/toto (ctime=1584810308)
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:38 : INFO : Listening for inotify events...
Sat Mar 21 21:06:38 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:38 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:38 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:38 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:38 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,toto,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:38 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:38 : INFO : [log][IN_CLOSE_NOWRITE] 0 : /tmp/test-extraarg-test.sh-1/toto (ctime=1584810308)
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:38 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:38 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:38 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:38 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:38 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,toto,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:38 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:38 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:38 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:39 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:39 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:39 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swx) : No such file or directory
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : INFO : plg_clamav(clamav) : No virus detected
Sat Mar 21 21:06:39 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swx) : No such file or directory
Sat Mar 21 21:06:39 : ERROR : plg_clamav(clamav) : error: Can't open file or directory
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : INFO : [log][IN_CLOSE_WRITE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swx (ctime=)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:39 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swx) : No such file or directory
Sat Mar 21 21:06:39 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:39 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:39 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:39 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swx,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : INFO : [log][IN_DELETE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swx (ctime=)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:39 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:39 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:39 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swx,metadata=test1,0" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : INFO : [log][IN_CLOSE_WRITE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swp (ctime=1584821199)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:39 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : INFO : plg_clamav(clamav) : No virus detected
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:39 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:39 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swp,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:39 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : INFO : [log][IN_DELETE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swp (ctime=)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:39 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:39 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:39 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swp,metadata=test1,0" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:39 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 5/16)
Sat Mar 21 21:06:39 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 4/16)
Sat Mar 21 21:06:39 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : INFO : [log][IN_CLOSE_NOWRITE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swp (ctime=1584821199)
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:39 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:39 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:39 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swp,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:39 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:39 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:39 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:41 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:41 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 1/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : INFO : [log][IN_CLOSE_WRITE] 0 : /tmp/test-extraarg-test.sh-1/virus.txt (ctime=1584821201)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:41 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:41 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,virus.txt,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:41 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:41 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swp) : No such file or directory
Sat Mar 21 21:06:41 : INFO : plg_clamav(clamav) : Virus detected: Eicar-Signature
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : INFO : plg_clamav(clamav) : No virus detected
Sat Mar 21 21:06:41 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swp) : No such file or directory
Sat Mar 21 21:06:41 : ERROR : plg_clamav(clamav) : error: Can't open file or directory
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : INFO : [log][IN_CLOSE_WRITE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swp (ctime=)
Sat Mar 21 21:06:41 : ERROR : lstat error on (/tmp/test-extraarg-test.sh-1/.virus.txt.swp) : No such file or directory
Sat Mar 21 21:06:41 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:41 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:41 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:41 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:41 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swp,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:41 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : INFO : [log][IN_DELETE] 0 : /tmp/test-extraarg-test.sh-1/.virus.txt.swp (ctime=)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:41 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:41 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:41 : DEBUG : event inotify from descriptor 1
Sat Mar 21 21:06:41 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,.virus.txt.swp,metadata=test1,0" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:41 : DEBUG : dirname=/tmp/test-extraarg-test.sh-1 descriptor=1 = 1
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (clamav) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (clamav) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:41 : DEBUG : Start plugin execution (exec) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : INFO : [log][IN_CLOSE_NOWRITE] 0 : /tmp/test-extraarg-test.sh-1/virus.txt (ctime=1584821201)
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (log) in separate thread (nbthread = 3/16)
Sat Mar 21 21:06:41 : DEBUG : extra_post_data=watch_directory.0.extra_post_data
Sat Mar 21 21:06:41 : DEBUG : handle - plg_notify_exec
Sat Mar 21 21:06:41 : DEBUG : Execute cmd: echo "/tmp/test-extraarg-test.sh-1,virus.txt,metadata=test1,1" >> /tmp/mgoulin-result.csv
Sat Mar 21 21:06:41 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 2/16)
Sat Mar 21 21:06:41 : DEBUG : Cmd return status = 0
Sat Mar 21 21:06:41 : DEBUG : End of execution plugin (exec) in separate thread (nbthread = 1/16)
^CSun Mar 22 08:16:59 : INFO : received SIGING => exit
Sun Mar 22 08:16:59 : DEBUG : Close plugin : libplg_notify_exec.so
Sun Mar 22 08:16:59 : DEBUG : Close plugin : libplg_notify_log.so
Sun Mar 22 08:16:59 : DEBUG : Close plugin : libplg_clamav.so
=================================================================
==17373==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 720 byte(s) in 5 object(s) allocated from:
#0 0x7f4351f17330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 (closed) 0x55ccec54afba in filenotify_get_filestat /home/matgou/workspace/filenotify/src/filenotify.c:147
#2 (closed) 0x55ccec54b396 in filenotify_execplugins /home/matgou/workspace/filenotify/src/filenotify.c:197
#3 0x55ccec54ccbe in engine_handleevents /home/matgou/workspace/filenotify/src/inotify_engine.c:104
#4 (closed) 0x55ccec54ad36 in filenotify_mainloop /home/matgou/workspace/filenotify/src/filenotify.c:102
#5 (closed) 0x55ccec54a8cc in main /home/matgou/workspace/filenotify/src/filenotify.c:582
#6 (closed) 0x7f4351c6b09a in __libc_start_main ../csu/libc-start.c:308
Direct leak of 264 byte(s) in 6 object(s) allocated from:
#0 0x7f4351f17330 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe9330)
#1 (closed) 0x55ccec54afda in filenotify_get_filestat /home/matgou/workspace/filenotify/src/filenotify.c:148
#2 (closed) 0x55ccec54b396 in filenotify_execplugins /home/matgou/workspace/filenotify/src/filenotify.c:197
#3 0x55ccec54ccbe in engine_handleevents /home/matgou/workspace/filenotify/src/inotify_engine.c:104
#4 (closed) 0x55ccec54ad36 in filenotify_mainloop /home/matgou/workspace/filenotify/src/filenotify.c:102
#5 (closed) 0x55ccec54a8cc in main /home/matgou/workspace/filenotify/src/filenotify.c:582
#6 (closed) 0x7f4351c6b09a in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: 984 byte(s) leaked in 11 allocation(s).