[syslog-ng] [Bug 278] New: Many memory leak problems happen when do configuration reloading

bugzilla at bugzilla.balabit.com bugzilla at bugzilla.balabit.com
Tue Apr 15 07:53:45 CEST 2014


https://bugzilla.balabit.com/show_bug.cgi?id=278

           Summary: Many memory leak problems happen when do configuration
                    reloading
           Product: syslog-ng
           Version: 3.5.x
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: unspecified
         Component: syslog-ng
        AssignedTo: bazsi at balabit.hu
        ReportedBy: xufeng.zhang at windriver.com
Type of the Report: ---
   Estimated Hours: 0.0


Created an attachment (id=95)
 --> (https://bugzilla.balabit.com/attachment.cgi?id=95)
the config and script files to reproduce this problem

I found many memory leak problems on syslog-ng_3.5.4.1, I have resolved some
of them, but there are still some others need to be resolved:
1). mutex problem such as:
==1077== 40 bytes in 1 blocks are definitely lost in loss record 514 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x36886024FE: ??? (in /lib64/libgthread-2.0.so.0.2600.0)
==1077==    by 0x3688266B23: g_static_mutex_get_mutex_impl (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x523D83C: affile_dw_queue (affile-dest.c:263)
==1077==    by 0x523D05B: affile_dd_queue (logpipe.h:320)
==1077==    by 0x3688E32150: log_multiplexer_queue (logpipe.h:320)
patch Fix-the-memory-leak-problem-for-mutex.patch could resolve them.

2). memory leak when HAVE_ENVIRON is defined:
==1077== 1,258 (208 direct, 1,050 indirect) bytes in 1 blocks are definitely lost in loss record 617 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E2F5FF: g_process_set_argv_space (gprocess.c:502)
==1077==    by 0x40164C: main (main.c:196)
patch Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch could resolve them.

3). memory leak problem for unconsumed item during configuration reloading:
==1077== 36,864 bytes in 45 blocks are definitely lost in loss record 636 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E3D178: log_writer_flush (logwriter.c:973)
==1077==    by 0x3688E3D2D2: log_writer_deinit (logwriter.c:1169)
==1077==    by 0x523C09A: affile_dw_deinit (logpipe.h:268)
==1077==    by 0x523C93B: affile_dd_deinit (logpipe.h:268)
==1077==    by 0x3688E2A4FE: cfg_tree_stop (logpipe.h:268)
==1077==    by 0x3688E3DB9F: main_loop_reload_config_apply (mainloop.c:540)
==1077==    by 0x3688E644DA: iv_signal_event (iv_signal.c:170)
==1077==    by 0x3688E62F28: iv_event_raw_got_event (iv_event_raw_posix.c:89)
==1077==    by 0x3688E635F1: iv_fd_poll_and_run (iv_fd.c:163)
==1077==    by 0x3688E63D73: iv_main (iv_main_posix.c:117)
patch logwriter-still-free-the-unconsumed-item.patch

4). The remaining memory leak problems need to be resolved, and they are not in 3.4.2 version:
==1077== 24 bytes in 1 blocks are definitely lost in loss record 483 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x5023BCA: socket_options_new (socket-options.c:90)
==1077==    by 0x502568A: afunix_sd_new_instance (afunix-source.c:241)
==1077==    by 0x502691A: afsocket_parse (afsocket-grammar.y:537)
==1077==    by 0x3688E440D1: plugin_parse_config (cfg-parser.h:83)
==1077==    by 0x3688E4F0BC: main_parse (cfg-grammar.y:549)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3DAE5: main_loop_reload_config_initiate (mainloop.c:611)
==1077==    by 0x3688E644DA: iv_signal_event (iv_signal.c:170)
==1077==    by 0x3688E62F28: iv_event_raw_got_event (iv_event_raw_posix.c:89)
==1077==
==1077== 24 bytes in 1 blocks are definitely lost in loss record 484 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x5023BCA: socket_options_new (socket-options.c:90)
==1077==    by 0x502568A: afunix_sd_new_instance (afunix-source.c:241)
==1077==    by 0x502691A: afsocket_parse (afsocket-grammar.y:537)
==1077==    by 0x3688E440D1: plugin_parse_config (cfg-parser.h:83)
==1077==    by 0x3688E4F0BC: main_parse (cfg-grammar.y:549)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3E42E: main_loop_init (mainloop.c:729)
==1077==    by 0x401774: main (main.c:246)

==1077== 64 bytes in 1 blocks are definitely lost in loss record 531 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x5025A81: transport_mapper_unix_new_instance (transport-mapper-unix.c:40)
==1077==    by 0x5025B04: transport_mapper_unix_dgram_new (transport-mapper-unix.c:51)
==1077==    by 0x50257C8: afunix_sd_new_dgram (afunix-source.c:262)
==1077==    by 0x502691A: afsocket_parse (afsocket-grammar.y:537)
==1077==    by 0x3688E440D1: plugin_parse_config (cfg-parser.h:83)
==1077==    by 0x3688E4F0BC: main_parse (cfg-grammar.y:549)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3DAE5: main_loop_reload_config_initiate (mainloop.c:611)
==1077==    by 0x3688E644DA: iv_signal_event (iv_signal.c:170)
==1077==
==1077== 64 bytes in 1 blocks are definitely lost in loss record 532 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x5025A81: transport_mapper_unix_new_instance (transport-mapper-unix.c:40)
==1077==    by 0x5025B04: transport_mapper_unix_dgram_new (transport-mapper-unix.c:51)
==1077==    by 0x50257C8: afunix_sd_new_dgram (afunix-source.c:262)
==1077==    by 0x502691A: afsocket_parse (afsocket-grammar.y:537)
==1077==    by 0x3688E440D1: plugin_parse_config (cfg-parser.h:83)
==1077==    by 0x3688E4F0BC: main_parse (cfg-grammar.y:549)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3E42E: main_loop_init (mainloop.c:729)
==1077==    by 0x401774: main (main.c:246)

==1077== 96 (24 direct, 72 indirect) bytes in 1 blocks are definitely lost in loss record 541 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368825CC99: g_slice_alloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368823D14D: g_list_prepend (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E5DE0A: log_template_add_macro_elem (templates.c:778)
==1077==    by 0x3688E5EC74: log_template_compile (templates.c:1232)
==1077==    by 0x3688E507AF: main_parse (cfg-grammar.y:741)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3DAE5: main_loop_reload_config_initiate (mainloop.c:611)
==1077==    by 0x3688E644DA: iv_signal_event (iv_signal.c:170)
==1077==    by 0x3688E62F28: iv_event_raw_got_event (iv_event_raw_posix.c:89)
==1077== 144 (48 direct, 96 indirect) bytes in 2 blocks are definitely lost in loss record 556 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368825CC99: g_slice_alloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368823D14D: g_list_prepend (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E5DE0A: log_template_add_macro_elem (templates.c:778)
==1077==    by 0x3688E5E661: log_template_compiler_process_token (templates.c:1129)
==1077==    by 0x3688E5EBD8: log_template_compile (templates.c:1222)
==1077==    by 0x3688E507AF: main_parse (cfg-grammar.y:741)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)
==1077==    by 0x3688E26ED5: cfg_read_config (cfg.c:382)
==1077==    by 0x3688E3E42E: main_loop_init (mainloop.c:729)
==1077==    by 0x401774: main (main.c:246)
==1077== 1,008 bytes in 42 blocks are definitely lost in loss record 606 of 636
==1077==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x36882478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368825CC99: g_slice_alloc (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x368823D14D: g_list_prepend (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E5DE0A: log_template_add_macro_elem (templates.c:778)
==1077==    by 0x3688E5EC74: log_template_compile (templates.c:1232)
==1077==    by 0x523BC1E: affile_dd_new_instance (affile-dest.c:706)
==1077==    by 0x523BCA8: affile_dd_new (affile-dest.c:722)
==1077==    by 0x523EEED: affile_parse (affile-grammar.y:490)
==1077==    by 0x3688E440D1: plugin_parse_config (cfg-parser.h:83)
==1077==    by 0x3688E4FFCA: main_parse (cfg-grammar.y:641)
==1077==    by 0x3688E26DC2: cfg_run_parser (cfg-parser.h:83)


==1077== 176 bytes in 1 blocks are definitely lost in loss record 563 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E44299: poll_fd_events_new (poll-fd-events.c:77)
==1077==    by 0x5022582: afsocket_sc_init (afsocket-source.c:91)
==1077==    by 0x5021FC7: afsocket_sd_process_connection (logpipe.h:253)
==1077==    by 0x5022B6D: afsocket_sd_init_method (afsocket-source.c:540)
==1077==    by 0x5025855: afunix_sd_init (afunix-source.c:223)
==1077==    by 0x3688E2BAF2: cfg_tree_start (logpipe.h:253)
==1077==    by 0x3688E2716A: cfg_init (cfg.c:218)
==1077==    by 0x3688E3E48C: main_loop_init (mainloop.c:527)
==1077==    by 0x401774: main (main.c:246)
==1077==
==1077== 176 bytes in 1 blocks are definitely lost in loss record 564 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E44299: poll_fd_events_new (poll-fd-events.c:77)
==1077==    by 0x523AC56: affile_sd_construct_poll_events (affile-source.c:195)
==1077==    by 0x523B696: affile_sd_init (affile-source.c:375)
==1077==    by 0x3688E2BAF2: cfg_tree_start (logpipe.h:253)
==1077==    by 0x3688E2716A: cfg_init (cfg.c:218)
==1077==    by 0x3688E3E48C: main_loop_init (mainloop.c:527)
==1077==    by 0x401774: main (main.c:246)
==1077== 352 bytes in 2 blocks are definitely lost in loss record 576 of 636
==1077==    at 0x4A04961: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1077==    by 0x3688247819: g_malloc0 (in /lib64/libglib-2.0.so.0.2600.0)
==1077==    by 0x3688E44299: poll_fd_events_new (poll-fd-events.c:77)
==1077==    by 0x523AC56: affile_sd_construct_poll_events (affile-source.c:195)
==1077==    by 0x523B696: affile_sd_init (affile-source.c:375)
==1077==    by 0x3688E2BAF2: cfg_tree_start (logpipe.h:253)
==1077==    by 0x3688E2716A: cfg_init (cfg.c:218)
==1077==    by 0x3688E3DBBE: main_loop_reload_config_apply (mainloop.c:543)
==1077==    by 0x3688E644DA: iv_signal_event (iv_signal.c:170)
==1077==    by 0x3688E62F28: iv_event_raw_got_event (iv_event_raw_posix.c:89)
==1077==    by 0x3688E635F1: iv_fd_poll_and_run (iv_fd.c:163)
==1077==    by 0x3688E63D73: iv_main (iv_main_posix.c:117)


When udp connection is used, I found three new additional memory leaks(I have applied the attached three patches):
==25796== 3,072 bytes in 3 blocks are definitely lost in loss record 616 of 622
==25796==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25796==    by 0x3B742478F4: g_malloc (in /lib64/libglib-2.0.so.0.2600.0)
==25796==    by 0x3B74E3D1D8: log_writer_flush (logwriter.c:974)
==25796==    by 0x3B74E3D2BC: log_writer_work_perform (logwriter.c:163)
==25796==    by 0x3B74E3D327: log_writer_io_flush_output (logwriter.c:243)
==25796==    by 0x3B74E63666: iv_fd_poll_and_run (iv_fd.c:167)
==25796==    by 0x3B74E63E13: iv_main (iv_main_posix.c:117)
==25796==    by 0x3B74E3D7E6: main_loop_run (mainloop.c:788)
==25796==    by 0x4017A0: main (main.c:267)

==25796== 20 bytes in 2 blocks are definitely lost in loss record 17 of 622
==25796==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25796==    by 0x3B6FA7C6B1: strdup (strdup.c:43)
==25796==    by 0x3B74E4D082: _cfg_lexer_lex (cfg-lex.l:205)
==25796==    by 0x3B74E293A1: cfg_lexer_lex (cfg-lexer.c:759)
==25796==    by 0x3B74E5C7A6: rewrite_expr_parse (rewrite-expr-grammar.c:2824)
==25796==    by 0x3B74E4EDD2: T.102 (cfg-parser.h:83)
==25796==    by 0x3B74E5016D: main_parse (cfg-grammar.y:606)
==25796==    by 0x3B74E26DC2: cfg_run_parser (cfg-parser.h:83)
==25796==    by 0x3B74E26ED5: cfg_read_config (cfg.c:382)
==25796==    by 0x3B74E3E4CE: main_loop_init (mainloop.c:729)
==25796==    by 0x401774: main (main.c:246)
==25796== 40 bytes in 4 blocks are definitely lost in loss record 514 of 622
==25796==    at 0x4A05F58: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25796==    by 0x3B6FA7C6B1: strdup (strdup.c:43)
==25796==    by 0x3B74E4D082: _cfg_lexer_lex (cfg-lex.l:205)
==25796==    by 0x3B74E293A1: cfg_lexer_lex (cfg-lexer.c:759)
==25796==    by 0x3B74E5C7A6: rewrite_expr_parse (rewrite-expr-grammar.c:2824)
==25796==    by 0x3B74E4EDD2: T.102 (cfg-parser.h:83)
==25796==    by 0x3B74E5016D: main_parse (cfg-grammar.y:606)
==25796==    by 0x3B74E26DC2: cfg_run_parser (cfg-parser.h:83)
==25796==    by 0x3B74E26ED5: cfg_read_config (cfg.c:382)
==25796==    by 0x3B74E3DB85: main_loop_reload_config_initiate (mainloop.c:611)
==25796==    by 0x3B74E6457A: iv_signal_event (iv_signal.c:170)
==25796==    by 0x3B74E62FC8: iv_event_raw_got_event (iv_event_raw_posix.c:89)


-- 
Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the syslog-ng mailing list