Skip to content

There is a memory leak in the lldp code #11170

Closed

Description

@evverx

Although the leak has always been there, It has just been discovered in #11140 with a simple test that just sends more than 2 different messages:

==6869==ERROR: LeakSanitizer: detected memory leaks



Direct leak of 201 byte(s) in 1 object(s) allocated from:

    #0 0x5630c8ec6e5f in calloc (/build/build/test-lldp+0xfde5f)

    #1 0x5630c8f0b96d in lldp_neighbor_new /build/build/../src/libsystemd-network/lldp-neighbor.c:99:13

    #2 0x5630c8f19b4a in lldp_receive_datagram /build/build/../src/libsystemd-network/sd-lldp.c:208:13

    #3 0x7f217382f8fc in source_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:2816:21

    #4 0x7f217382dbf9 in sd_event_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:3229:21

    #5 0x7f2173832b80 in sd_event_run /build/build/../src/libsystemd/sd-event/sd-event.c:3286:21

    #6 0x5630c8f07d98 in test_multiple_neighbors_sorted /build/build/../src/libsystemd-network/test-lldp.c:326:9

    #7 0x5630c8f03bf3 in main /build/build/../src/libsystemd-network/test-lldp.c:371:9

    #8 0x7f2172938412 in __libc_start_main (/lib64/libc.so.6+0x24412)



Indirect leak of 5 byte(s) in 1 object(s) allocated from:

    #0 0x5630c8ec6c1f in __interceptor_malloc (/build/build/test-lldp+0xfdc1f)

    #1 0x7f21733764d9 in memdup /build/build/../src/basic/alloc-util.c:15:15

    #2 0x5630c8f0d252 in lldp_neighbor_parse /build/build/../src/libsystemd-network/lldp-neighbor.c:222:44

    #3 0x5630c8f1ecb3 in lldp_handle_datagram /build/build/../src/libsystemd-network/sd-lldp.c:179:13

    #4 0x5630c8f1a263 in lldp_receive_datagram /build/build/../src/libsystemd-network/sd-lldp.c:231:16

    #5 0x7f217382f8fc in source_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:2816:21

    #6 0x7f217382dbf9 in sd_event_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:3229:21

    #7 0x7f2173832b80 in sd_event_run /build/build/../src/libsystemd/sd-event/sd-event.c:3286:21

    #8 0x5630c8f07d98 in test_multiple_neighbors_sorted /build/build/../src/libsystemd-network/test-lldp.c:326:9

    #9 0x5630c8f03bf3 in main /build/build/../src/libsystemd-network/test-lldp.c:371:9

    #10 0x7f2172938412 in __libc_start_main (/lib64/libc.so.6+0x24412)



Indirect leak of 4 byte(s) in 1 object(s) allocated from:

    #0 0x5630c8ec6c1f in __interceptor_malloc (/build/build/test-lldp+0xfdc1f)

    #1 0x7f21733764d9 in memdup /build/build/../src/basic/alloc-util.c:15:15

    #2 0x5630c8f0d802 in lldp_neighbor_parse /build/build/../src/libsystemd-network/lldp-neighbor.c:239:41

    #3 0x5630c8f1ecb3 in lldp_handle_datagram /build/build/../src/libsystemd-network/sd-lldp.c:179:13

    #4 0x5630c8f1a263 in lldp_receive_datagram /build/build/../src/libsystemd-network/sd-lldp.c:231:16

    #5 0x7f217382f8fc in source_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:2816:21

    #6 0x7f217382dbf9 in sd_event_dispatch /build/build/../src/libsystemd/sd-event/sd-event.c:3229:21

    #7 0x7f2173832b80 in sd_event_run /build/build/../src/libsystemd/sd-event/sd-event.c:3286:21

    #8 0x5630c8f07d98 in test_multiple_neighbors_sorted /build/build/../src/libsystemd-network/test-lldp.c:326:9

    #9 0x5630c8f03bf3 in main /build/build/../src/libsystemd-network/test-lldp.c:371:9

    #10 0x7f2172938412 in __libc_start_main (/lib64/libc.so.6+0x24412)



SUMMARY: AddressSanitizer: 210 byte(s) leaked in 3 allocation(s).

-------

The fix is pending in #11163.

Activity

  1. added
    bug 🐛
    priority
    on Dec 15, 2018
  2. evverx commented on Dec 15, 2018

    @evverx
    ContributorAuthor

    The commit where the test was introduced has just been reverted so I'm removing the "priority" label.

  3. removed
    priority
    on Dec 15, 2018
  4. self-assigned this
    on Dec 15, 2018
  5. added this to the v240 milestone on Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛lldp

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions