[forkserver] Valgrind reports memory leaks on strdup()ed env/arg strings
Categories
(Core :: IPC, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox124 | --- | fixed |
People
(Reporter: jld, Assigned: jld)
References
Details
Attachments
(1 file)
Found while testing a patch for bug 1875415: Valgrind also complains about memory leaks of various strdup()
ed strings when the fork server is enabled. These strings are part of argv/environ vectors at some point — we replace the original argv with heap-allocated strings copied from an IPC message, and we also relocate the original arg/env strings to the heap so we can overwrite the original arg/env space to implement setproctitle
. However, they become unreachable before the process exits — if they're dropped from the argv vector by a function like our CheckArg
or dropped from the environment by libc's setenv
.
There really isn't a way to free the strings when they become unreachable. It would be possible to save copies of the pointers in an otherwise unused vector or something to make them “not leaked”, but it looks like we're willing to use valgrind suppressions in the case of setenv-like intentional leaks (bug 793548, bug 793549, bug 944133, and others).
Assignee | ||
Comment 1•1 years ago
|
||
The fork server replaces the process's argv
and environ
with
heap-allocated strings received over IPC; if those strings are later
unlinked from those vectors, they will be seen as leaked. Also, we
have an implementation of setproctitle
(a BSD feature that has to be
emulated somewhat hackily on Linux) which copies the process's original
argv
and environ
strings into the heap so the original space can be
reused; this can also cause (finite) leaks when those strings are later
discarded.
Given that we already tell Valgrind to ignore leaks caused by use of
setenv
and similar, this patch likewise suppresses those leaks.
Comment 3•1 years ago
|
||
bugherder |
Description
•