Closed nikobockerman closed 3 years ago
I found some documentation for wl_list and now I understand how those linked lists work. I hadn't seen such use of offsetof()
but it's quite convinient way to implement doubly-linked list.
I'll prepare a merge request to free()
those strings allocated in parse_timeout.
how that code can work at all as it seems to me that the
cmd
is not stored anywhere, only thecmd->link
member is stored in thestate->timeout_cmds
list.
This is a common pattern in Wayland (and incidentally kernel) code, see https://wayland.freedesktop.org/docs/html/apb.html#Client-structwl__list.
In fact, I suspect that's what's tripping LeakSanitizer up. LeakSanitizer assumes heap blocks not reachable from the stack at shutdown are leaks, but with the wl_list
pattern it's not obvious that swayidle_timeout_cmd *cmd
is still referred to by the stack.
Argh, raced by 12 seconds.
Thanks for the link in any case, it had even better information than what I initially read :+1:
I opened #93 as those two members were never freed, and LeakSanitizer detected that.
After that change, the first two leaks triggered by libwayland-client.so
and libwayland-server.so
are still present, but those are probably not caused by swayidle.
Hi,
I tried running swayidle with clang address sanitizer and LeakSanitizer reported the following leaks when I stopped swayidle:
This was from a build against latest master (7dafac7) + cherry-picked commit from #83 (8ccea65f1714e4594c1c488d9f3a10bbb68140bd).
I tried to analyze the two leaks from
parse_command()
when called fromparse_timeout()
. However, I fail to understand how that code can work at all as it seems to me that thecmd
is not stored anywhere, only thecmd->link
member is stored in thestate->timeout_cmds
list.Do you consider these real problems? And do you want me to provide some extra information?
I could even try to fix those leaks myself and issue a PR, but I don't understand how the code even works today so can't do that without someone explaining that first :)