ospfd: ospf_spf_vertex_parent_copy leak
After addressing and debugging the code for leaks, three leaks persist, with one located below. Despite employing tools like GDB, my team is encountering challenges in resolving this specific leak. We would appreciate a review and any advice you can provide.
***********************************************************************************
Address Sanitizer Error detected in ospf_tilfa_topo1.test_ospf_tilfa_topo1/rt1.asan.ospfd.18993
=================================================================
==18993==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 128 byte(s) in 4 object(s) allocated from:
#0 0x7fc466d95d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
#1 0x7fc466794049 in qcalloc lib/memory.c:105
#2 0x55ed0fb22335 in ospf_spf_vertex_parent_copy ospfd/ospf_spf.c:350
#3 0x55ed0fb22335 in ospf_spf_copy ospfd/ospf_spf.c:391
#4 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#5 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#6 0x55ed0fb2c134 in ospf_ti_lfa_generate_p_space ospfd/ospf_ti_lfa.c:787
#7 0x55ed0fb2cbce in ospf_ti_lfa_generate_p_spaces ospfd/ospf_ti_lfa.c:923
#8 0x55ed0fb2ce02 in ospf_ti_lfa_compute ospfd/ospf_ti_lfa.c:1101
#9 0x55ed0fb24ca1 in ospf_spf_calculate_area ospfd/ospf_spf.c:1811
#10 0x55ed0fb24e2b in ospf_spf_calculate_areas ospfd/ospf_spf.c:1840
#11 0x55ed0fb251ee in ospf_spf_calculate_schedule_worker ospfd/ospf_spf.c:1871
#12 0x7fc466833b7a in event_call lib/event.c:1965
#13 0x7fc4667772b0 in frr_run lib/libfrr.c:1214
#14 0x55ed0fabb0a9 in main ospfd/ospf_main.c:251
#15 0x7fc465d8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
Direct leak of 128 byte(s) in 4 object(s) allocated from:
#0 0x7fc466d95d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
#1 0x7fc466794049 in qcalloc lib/memory.c:105
#2 0x55ed0fb22335 in ospf_spf_vertex_parent_copy ospfd/ospf_spf.c:350
#3 0x55ed0fb22335 in ospf_spf_copy ospfd/ospf_spf.c:391
#4 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#5 0x55ed0fb2c134 in ospf_ti_lfa_generate_p_space ospfd/ospf_ti_lfa.c:787
#6 0x55ed0fb2cbce in ospf_ti_lfa_generate_p_spaces ospfd/ospf_ti_lfa.c:923
#7 0x55ed0fb2ce02 in ospf_ti_lfa_compute ospfd/ospf_ti_lfa.c:1101
#8 0x55ed0fb24ca1 in ospf_spf_calculate_area ospfd/ospf_spf.c:1811
#9 0x55ed0fb24e2b in ospf_spf_calculate_areas ospfd/ospf_spf.c:1840
#10 0x55ed0fb251ee in ospf_spf_calculate_schedule_worker ospfd/ospf_spf.c:1871
#11 0x7fc466833b7a in event_call lib/event.c:1965
#12 0x7fc4667772b0 in frr_run lib/libfrr.c:1214
#13 0x55ed0fabb0a9 in main ospfd/ospf_main.c:251
#14 0x7fc465d8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
Direct leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x7fc466d95d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
#1 0x7fc466794049 in qcalloc lib/memory.c:105
#2 0x55ed0fb22335 in ospf_spf_vertex_parent_copy ospfd/ospf_spf.c:350
#3 0x55ed0fb22335 in ospf_spf_copy ospfd/ospf_spf.c:391
#4 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#5 0x55ed0fb2c134 in ospf_ti_lfa_generate_p_space ospfd/ospf_ti_lfa.c:787
#6 0x55ed0fb2c86e in ospf_ti_lfa_generate_p_spaces ospfd/ospf_ti_lfa.c:874
#7 0x55ed0fb2ce02 in ospf_ti_lfa_compute ospfd/ospf_ti_lfa.c:1101
#8 0x55ed0fb24ca1 in ospf_spf_calculate_area ospfd/ospf_spf.c:1811
#9 0x55ed0fb24e2b in ospf_spf_calculate_areas ospfd/ospf_spf.c:1840
#10 0x55ed0fb251ee in ospf_spf_calculate_schedule_worker ospfd/ospf_spf.c:1871
#11 0x7fc466833b7a in event_call lib/event.c:1965
#12 0x7fc4667772b0 in frr_run lib/libfrr.c:1214
#13 0x55ed0fabb0a9 in main ospfd/ospf_main.c:251
#14 0x7fc465d8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
Direct leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x7fc466d95d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
#1 0x7fc466794049 in qcalloc lib/memory.c:105
#2 0x55ed0fb22335 in ospf_spf_vertex_parent_copy ospfd/ospf_spf.c:350
#3 0x55ed0fb22335 in ospf_spf_copy ospfd/ospf_spf.c:391
#4 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#5 0x55ed0fb227e6 in ospf_spf_copy ospfd/ospf_spf.c:408
#6 0x55ed0fb2c134 in ospf_ti_lfa_generate_p_space ospfd/ospf_ti_lfa.c:787
#7 0x55ed0fb2c86e in ospf_ti_lfa_generate_p_spaces ospfd/ospf_ti_lfa.c:874
#8 0x55ed0fb2ce02 in ospf_ti_lfa_compute ospfd/ospf_ti_lfa.c:1101
#9 0x55ed0fb24ca1 in ospf_spf_calculate_area ospfd/ospf_spf.c:1811
#10 0x55ed0fb24e2b in ospf_spf_calculate_areas ospfd/ospf_spf.c:1840
#11 0x55ed0fb251ee in ospf_spf_calculate_schedule_worker ospfd/ospf_spf.c:1871
#12 0x7fc466833b7a in event_call lib/event.c:1965
#13 0x7fc4667772b0 in frr_run lib/libfrr.c:1214
#14 0x55ed0fabb0a9 in main ospfd/ospf_main.c:251
#15 0x7fc465d8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
Hello,
For TI-LFA, it is needed to compute the P and Q space to determine alternate route in case of link or node failure. For this purpose, the P space need its own copy of the SPF, thus the vertex. Unfortunately, when OSPF shutdown, the vertex allocated for TI-LFA are not free. I'll have a look to the code to determine if this allocated vertex are free when TI-LFA is stopped and thus which piece of code should be added when OSPF is shutdown. If there is no such code in TI-LFA, I'll look how to create such function.
Regards
Olivier
In fact, it is the same problem as issue #14783
This issue is stale because it has been open 180 days with no activity. Comment or remove the autoclose label in order to avoid having this issue closed.
This issue will be automatically closed in the specified period unless there is further activity.