Skip to content

There seems to be a memory leak in systemd #11251

@evverx

Description

@evverx

It happens when systemd tries to deserialize units:

Direct leak of 8192 byte(s) in 128 object(s) allocated from:
    #0 0x7f3f5c337088 in __interceptor_realloc (/lib64/libasan.so.5+0xef088)
    #1 0x7f3f5b28a1e9 in greedy_realloc ../src/basic/alloc-util.c:55
    #2 0x7f3f5b2eb0dc in read_line_full ../src/basic/fileio.c:727
    #3 0x56236ae597ef in read_line ../src/basic/fileio.h:71
    #4 0x56236ae84dc4 in manager_deserialize_units ../src/core/manager.c:3252
    #5 0x56236ae88305 in manager_deserialize ../src/core/manager.c:3464
    #6 0x56236ae8912d in manager_reload ../src/core/manager.c:3528
    #7 0x56236ad5b8f1 in invoke_main_loop ../src/core/main.c:1824
    #8 0x56236ad61fbd in main ../src/core/main.c:2574
    #9 0x7f3f5882311a in __libc_start_main (/lib64/libc.so.6+0x2311a)

SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 128 allocation(s).

Most likely it was introduced in 651b3b6. I have a patch I haven't tested yet:

diff --git a/src/core/manager.c b/src/core/manager.c
index 35d9753b1..6086531ba 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -3243,11 +3243,11 @@ static int manager_deserialize_one_unit(Manager *m, const char *name, FILE *f, F
 }

 static int manager_deserialize_units(Manager *m, FILE *f, FDSet *fds) {
-        _cleanup_free_ char *line = NULL;
         const char *unit_name;
         int r;

         for (;;) {
+                _cleanup_free_ char *line = NULL;
                 /* Start marker */
                 r = read_line(f, LONG_LINE_MAX, &line);
                 if (r < 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixingpid1

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions