FRRouting / frr

The FRRouting Protocol Suite
https://frrouting.org/
Other
3.38k stars 1.26k forks source link

ospf has memory leaks when running bfd-topo2/test_bfd_topo2.py #8475

Open donaldsharp opened 3 years ago

donaldsharp commented 3 years ago
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x1EFC78: ospf_external_info_new (ospf_asbr.c:80)
==848145==    by 0x1EFED3: ospf_external_info_add (ospf_asbr.c:145)
==848145==    by 0x1DC35E: ospf_zebra_read_route (ospf_zebra.c:1258)
==848145==    by 0x498423F: zclient_read (zclient.c:3751)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x490817E: frr_run (libfrr.c:1149)
==848145==    by 0x16AC4D: main (ospf_main.c:233)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 22,995 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x49633D4: _thread_add_read_write (thread.c:892)
==848145==    by 0x497082B: vty_event_serv (vty.c:2661)
==848145==    by 0x496F2BE: vty_serv_un (vty.c:1987)
==848145==    by 0x496F7B8: vty_serv_sock (vty.c:2167)
==848145==    by 0x4907C64: frr_vty_serv (libfrr.c:1018)
==848145==    by 0x4907FBE: frr_run (libfrr.c:1110)
==848145==    by 0x16AC4D: main (ospf_main.c:233)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 22,996 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x496367B: _thread_add_timer_timeval (thread.c:945)
==848145==    by 0x49637F9: _thread_add_timer (thread.c:981)
==848145==    by 0x1DF284: ospf_new (ospfd.c:418)
==848145==    by 0x1DF6AC: ospf_get (ospfd.c:511)
==848145==    by 0x1B7E0E: router_ospf (ospf_vty.c:224)
==848145==    by 0x48D1702: cmd_execute_command_real (command.c:964)
==848145==    by 0x48D1988: cmd_execute_command_strict (command.c:1072)
==848145==    by 0x48D1F13: command_config_read_one_line (command.c:1251)
==848145==    by 0x48D2080: config_from_file (command.c:1291)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 22,997 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x496367B: _thread_add_timer_timeval (thread.c:945)
==848145==    by 0x49638CD: _thread_add_timer_msec (thread.c:998)
==848145==    by 0x1A1919: ospf_spf_calculate_schedule (ospf_spf.c:1989)
==848145==    by 0x1F02AB: ospf_asbr_status_update (ospf_asbr.c:273)
==848145==    by 0x1DB418: ospf_redistribute_set (ospf_zebra.c:830)
==848145==    by 0x1CF358: ospf_redistribute_source (ospf_vty.c:9114)
==848145==    by 0x48D1702: cmd_execute_command_real (command.c:964)
==848145==    by 0x48D1988: cmd_execute_command_strict (command.c:1072)
==848145==    by 0x48D1E35: command_config_read_one_line (command.c:1231)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 22,998 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x496367B: _thread_add_timer_timeval (thread.c:945)
==848145==    by 0x49637F9: _thread_add_timer (thread.c:981)
==848145==    by 0x176C89: ism_timer_set (ospf_ism.c:314)
==848145==    by 0x1776B4: ospf_ism_event (ospf_ism.c:603)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x490817E: frr_run (libfrr.c:1149)
==848145==    by 0x16AC4D: main (ospf_main.c:233)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 22,999 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x4965987: _thread_execute (thread.c:1878)
==848145==    by 0x190109: ospf_db_desc (ospf_packet.c:1383)
==848145==    by 0x194112: ospf_read_helper (ospf_packet.c:3166)
==848145==    by 0x19424C: ospf_read (ospf_packet.c:3203)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x490817E: frr_run (libfrr.c:1149)
==848145==    by 0x16AC4D: main (ospf_main.c:233)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 23,000 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x4965987: _thread_execute (thread.c:1878)
==848145==    by 0x1878C2: nsm_change_state (ospf_nsm.c:659)
==848145==    by 0x187F9F: ospf_nsm_event (ospf_nsm.c:824)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x4965A0D: _thread_execute (thread.c:1889)
==848145==    by 0x190109: ospf_db_desc (ospf_packet.c:1383)
==848145==    by 0x194112: ospf_read_helper (ospf_packet.c:3166)
==848145==    by 0x19424C: ospf_read (ospf_packet.c:3203)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 23,001 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x49639BF: _thread_add_event (thread.c:1030)
==848145==    by 0x48CD660: bfd_sess_install (bfd.c:914)
==848145==    by 0x16AFC6: ospf_bfd_trigger_event (ospf_bfd.c:57)
==848145==    by 0x187CAA: nsm_change_state (ospf_nsm.c:765)
==848145==    by 0x187F9F: ospf_nsm_event (ospf_nsm.c:824)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x4965A0D: _thread_execute (thread.c:1889)
==848145==    by 0x190109: ospf_db_desc (ospf_packet.c:1383)
==848145==    by 0x194112: ospf_read_helper (ospf_packet.c:3166)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 23,002 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x496367B: _thread_add_timer_timeval (thread.c:945)
==848145==    by 0x49637F9: _thread_add_timer (thread.c:981)
==848145==    by 0x1869B2: nsm_timer_set (ospf_nsm.c:133)
==848145==    by 0x187FBF: ospf_nsm_event (ospf_nsm.c:830)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x4965A0D: _thread_execute (thread.c:1889)
==848145==    by 0x190109: ospf_db_desc (ospf_packet.c:1383)
==848145==    by 0x194112: ospf_read_helper (ospf_packet.c:3166)
==848145==    by 0x19424C: ospf_read (ospf_packet.c:3203)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 23,003 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x496367B: _thread_add_timer_timeval (thread.c:945)
==848145==    by 0x49637F9: _thread_add_timer (thread.c:981)
==848145==    by 0x186A19: nsm_timer_set (ospf_nsm.c:139)
==848145==    by 0x187FBF: ospf_nsm_event (ospf_nsm.c:830)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x4965A0D: _thread_execute (thread.c:1889)
==848145==    by 0x1903D0: ospf_db_desc (ospf_packet.c:1460)
==848145==    by 0x194112: ospf_read_helper (ospf_packet.c:3166)
==848145==    by 0x19424C: ospf_read (ospf_packet.c:3203)
==848145== 
==848145== 152 bytes in 1 blocks are possibly lost in loss record 23,004 of 23,831
==848145==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==848145==    by 0x4917883: qcalloc (memory.c:115)
==848145==    by 0x4962D2F: thread_get (thread.c:693)
==848145==    by 0x4965987: _thread_execute (thread.c:1878)
==848145==    by 0x1878C2: nsm_change_state (ospf_nsm.c:659)
==848145==    by 0x187F9F: ospf_nsm_event (ospf_nsm.c:824)
==848145==    by 0x496551E: thread_call (thread.c:1815)
==848145==    by 0x4965A0D: _thread_execute (thread.c:1889)
==848145==    by 0x172AD0: ospf_if_cleanup (ospf_interface.c:319)
==848145==    by 0x1772FB: ism_interface_down (ospf_ism.c:397)
==848145==    by 0x1775DB: ospf_ism_event (ospf_ism.c:588)
==848145==    by 0x496551E: thread_call (thread.c:1815)
rzalamena commented 3 years ago

PR #8409 fixes one part of it but there are more things left.

Instructions for people to test:

  1. Compile FRR without ASAN (this is the default)

  2. Add this patch to your topotest:

    diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
    index 104b21507..d68f46663 100644
    --- a/tests/topotests/lib/topotest.py
    +++ b/tests/topotests/lib/topotest.py
    @@ -1512,7 +1512,10 @@ class Router(Node):
                    ) + "/var/run/{}/snmpd.pid -x /etc/frr/agentx".format(self.routertype)
                else:
                    binary = os.path.join(self.daemondir, daemon)
    -                cmdenv = "ASAN_OPTIONS=log_path={0}.asan".format(daemon)
    +                if daemon == "ospfd":
    +                    cmdenv = "ASAN_OPTIONS=log_path={0}.asan valgrind --log-file=/tmp/valgrind/%p --leak-check=full ".format(daemon)
    +                else:
    +                    cmdenv = "ASAN_OPTIONS=log_path={0}.asan".format(daemon)
                    cmdopt = "{} --log file:{}.log --log-level debug".format(
                        daemon_opts, daemon
                    )
  3. Before running topotest create the valgrind output directory: mkdir /tmp/valgrind ; chmod 1777 /tmp/valgrind

  4. Run the bfd-topo2 topology test

  5. Read the /tmp/valgrind/* files

gpnaveen commented 3 years ago

@rgirada Pls check this once.