Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharpd: Set Callback Function for Memory Cleanup #14802

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

Keelan10
Copy link
Contributor

Implement a callback function for memory cleanup of sharp_nh_tracker. Specifically, set sharp_nh_tracker_free as the deletion function for the sg.nhs list. This ensures proper cleanup of resources when elements are removed.

The ASan leak log for reference:

***********************************************************************************
Address Sanitizer Error detected in zebra_nht_resolution.test_verify_nh_resolution/r1.asan.sharpd.32320

=================================================================
==32320==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f4ee812ad28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f4ee7b291cc in qcalloc lib/memory.c:105
    #2 0x5582be672011 in sharp_nh_tracker_get sharpd/sharp_nht.c:36
    #3 0x5582be680b42 in watch_nexthop_v4_magic sharpd/sharp_vty.c:139
    #4 0x5582be680b42 in watch_nexthop_v4 sharpd/sharp_vty_clippy.c:192
    #5 0x7f4ee7aac0b1 in cmd_execute_command_real lib/command.c:978
    #6 0x7f4ee7aac575 in cmd_execute_command lib/command.c:1036
    #7 0x7f4ee7aac9f4 in cmd_execute lib/command.c:1203
    #8 0x7f4ee7bd50bb in vty_command lib/vty.c:594
    #9 0x7f4ee7bd5566 in vty_execute lib/vty.c:1357
    #10 0x7f4ee7bdde37 in vtysh_read lib/vty.c:2365
    #11 0x7f4ee7bc8dfa in event_call lib/event.c:1965
    #12 0x7f4ee7b0c3bf in frr_run lib/libfrr.c:1214
    #13 0x5582be671252 in main sharpd/sharp_main.c:188
    #14 0x7f4ee6f1bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
***********************************************************************************

@frrbot frrbot bot added the sharp label Nov 15, 2023
Implement a callback function for memory cleanup of sharp_nh_tracker.
Specifically, set `sharp_nh_tracker_free` as the deletion function for the `sg.nhs` list.
This ensures proper cleanup of resources when elements are removed.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in zebra_nht_resolution.test_verify_nh_resolution/r1.asan.sharpd.32320

=================================================================
==32320==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f4ee812ad28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7f4ee7b291cc in qcalloc lib/memory.c:105
    FRRouting#2 0x5582be672011 in sharp_nh_tracker_get sharpd/sharp_nht.c:36
    FRRouting#3 0x5582be680b42 in watch_nexthop_v4_magic sharpd/sharp_vty.c:139
    FRRouting#4 0x5582be680b42 in watch_nexthop_v4 sharpd/sharp_vty_clippy.c:192
    FRRouting#5 0x7f4ee7aac0b1 in cmd_execute_command_real lib/command.c:978
    FRRouting#6 0x7f4ee7aac575 in cmd_execute_command lib/command.c:1036
    FRRouting#7 0x7f4ee7aac9f4 in cmd_execute lib/command.c:1203
    FRRouting#8 0x7f4ee7bd50bb in vty_command lib/vty.c:594
    FRRouting#9 0x7f4ee7bd5566 in vty_execute lib/vty.c:1357
    FRRouting#10 0x7f4ee7bdde37 in vtysh_read lib/vty.c:2365
    FRRouting#11 0x7f4ee7bc8dfa in event_call lib/event.c:1965
    FRRouting#12 0x7f4ee7b0c3bf in frr_run lib/libfrr.c:1214
    FRRouting#13 0x5582be671252 in main sharpd/sharp_main.c:188
    FRRouting#14 0x7f4ee6f1bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <[email protected]>
@donaldsharp donaldsharp merged commit 4cce1e4 into FRRouting:master Nov 15, 2023
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants