Mac OS X leak in nsUpdateDriver::ApplyUpdate
Categories
(Toolkit :: Application Update, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox67 | --- | fixed |
People
(Reporter: robert.strong.bugs, Assigned: spohl)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file, 1 obsolete file)
5.44 KB,
patch
|
robert.strong.bugs
:
review+
|
Details | Diff | Splinter Review |
Direct leak of 288 byte(s) in 6 object(s) allocated from:
#0 0x10d1fe233 in wrap_malloc (/usr/local/opt/llvm/lib/clang/7.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64+0x59233)
#1 0x10d143fad in moz_xmalloc (<objdir>/dist/Nightly.app/Contents/MacOS/libmozglue.dylib:x86_64+0x1fad)
#2 0x11ebb1451 in ApplyUpdate(nsIFile*, nsIFile*, nsIFile*, int, char**, bool, bool, int*) (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xd27b451)
#3 0x11ebafaa8 in ProcessUpdates(nsIFile*, nsIFile*, nsIFile*, int, char**, char const*, bool, int*) (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xd279aa8)
#4 0x11ebb4349 in nsUpdateProcessor::StartStagedUpdate() (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xd27e349)
#5 0x11ebc5827 in mozilla::detail::RunnableMethodImpl<nsUpdateProcessor*, void (nsUpdateProcessor::)(), true, (mozilla::RunnableKind)0>::Run() (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xd28f827)
#6 0x111bf40b3 in nsThread::ProcessNextEvent(bool, bool) (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0x2be0b3)
#7 0x111bfa7dd in NS_ProcessNextEvent(nsIThread*, bool) (<objdir>/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0x2c47dd)
Associated code
char **argv = new char *[argc + 1];
<snip>
#elif defined(XP_MACOSX)
UpdateDriverSetupMacCommandLine(argc, argv, restart);
UpdateDriverSetupMacCommandLine calls SetupMacCommandLine
and
void SetupMacCommandLine(int& argc, char**& argv, bool forRestart) {
sArgs = static_cast<char**>(malloc(kArgsGrowSize * sizeof(char*)));
<snip>
argc = sArgsUsed;
argv = sArgs;
}
Reporter | ||
Comment 1•6 years ago
|
||
Stephen, no rush but if you could fix this as time permits I'd appreciate it.
Assignee | ||
Comment 2•6 years ago
|
||
This changes SetupMacCommandLine
to release the passed-in argv
. This meant that we had to change to malloc
/free
everywhere that this function is called.
XRE_mainRun
had to allocate a temporary copy of gArgv
in one case, since we're now releasing it inside SetupMacCommandLine
. This is not an issue with the two other calls to SetupMacCommandLine
in nsAppRunner.cpp since it's using gRestartArgv
, which was malloc
'd.
I don't have time to test this out on Oak at the moment. Robert, would you mind taking this for a spin during the review? I wanted to post the patch as soon as possible, even if I didn't have time to test it out right now. Thank you!
Assignee | ||
Updated•6 years ago
|
Reporter | ||
Comment 3•6 years ago
|
||
Thanks Stephen! I had to clobber my LSAN build due to invalid symlinks in the .app. I'll comment in the bug after I test it out and will land it on oak to verify basic functionality around this code.
Reporter | ||
Comment 4•6 years ago
|
||
Assignee | ||
Comment 5•6 years ago
|
||
Reporter | ||
Comment 6•6 years ago
|
||
This fixes the leak in ApplyUpdate. The following now shows up in the log
rstrong/moz/_1_mozilla-central/ff-lsan-leak/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xe1e2077)
1:13.91 pid:59970 Direct leak of 823 byte(s) in 5 object(s) allocated from:
1:13.91 pid:59970 #0 0x10219b28c in wrap_strdup (/usr/local/opt/llvm/lib/clang/7.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64+0x5328c)
1:13.91 pid:59970 #1 0x11231791f in CommandLineServiceMac::SetupMacCommandLine(int&, char**&, bool) (/Users/rstrong/moz/_1_mozilla-central/ff-lsan-leak/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xdf5291f)
1:13.91 pid:59970 #2 0x112311872 in mozilla::detail::RunnableFunction<UpdateDriverSetupMacCommandLine(int&, char**&, bool)::$_0>::Run() (/Users/rstrong/moz/_1_mozilla-central/ff-lsan-leak/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0xdf4c872)
1:13.91 pid:59970 #3 0x1046c64d9 in nsThread::ProcessNextEvent(bool, bool*) (/Users/rstrong/moz/_1_mozilla-central/ff-lsan-leak/dist/Nightly.app/Contents/MacOS/XUL:x86_64+0x3014d9)
Assignee | ||
Comment 7•6 years ago
|
||
Okay, that looks like it's coming from AddToCommandLine
, and more specifically from the call to strdup
of which the result is never free
'd. This will require a bit of a rewrite to fix. Will take a look.
Reporter | ||
Comment 8•6 years ago
|
||
Assignee | ||
Comment 9•6 years ago
|
||
Assignee | ||
Comment 10•6 years ago
|
||
(In reply to Robert Strong (Robert he/him) [:rstrong] (use needinfo to contact me) from comment #8)
Please file a followup for the strdup leak
Filed bug 1530374.
Comment 11•6 years ago
|
||
bugherder |
Comment 12•6 years ago
|
||
== Change summary for alert #19641 (as of Mon, 25 Feb 2019 13:16:48 GMT) ==
Improvements:
19% Resident Memory windows7-32 pgo stylo 562,005,198.13 -> 455,057,513.54
For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=19641
Description
•