Closed
Bug 1354546
Opened 8 years ago
Closed 8 years ago
Make LUL read CFI from the main executable on x86_64-Linux
Categories
(Core :: Gecko Profiler, defect)
Core
Gecko Profiler
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: jseward, Assigned: jseward)
References
Details
Attachments
(1 file, 1 obsolete file)
9.47 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
LUL doesn't read CFI from the main executable on x86_64-linux, and possibly
other Linux variants, because SharedLibraryInfo::GetInfoForSelf() doesn't
produce a name for the main executable object, even though it does notice the
mapping.
This causes noticeable unwind breakage because the main executable on Linux
contains various wrapper functions pertaining to memory allocation and locking,
such as
moz_xmalloc, moz_xcalloc, moz_xrealloc
mozilla::detail::MutexImpl::lock, mozilla::detail::MutexImpl::unlock
A proper fix is to tidy up shared-libraries-linux.cc and make it able to
identify the main executable properly. As a short-term fix, we could simply
assume that any nameless object mapped at 0x400000 is the executable. 0x400000
is the "traditional" (x86_64-ELF mandated?) load address for executables on this
platform.
This will fail if the executable is position independent, but at least for
Fedora 25, Ubuntu 16.10 and probably for Debian, that's not the case by default.
This will also fail if (by some amazing chance) some other object with no name
gets mapped to 0x400000, since it will then be mis-identified as the executable.
This doesn't seem very likely, though.
Assignee | ||
Comment 1•8 years ago
|
||
Assignee | ||
Updated•8 years ago
|
Summary: Make LUL read CFI from the main executable on x86_64-Linux -- temporary fix → Make LUL read CFI from the main executable on x86_64-Linux
Assignee | ||
Comment 2•8 years ago
|
||
LUL doesn't read CFI from the main executable on x86_64-linux, and possibly
other Linux variants, because SharedLibraryInfo::GetInfoForSelf() doesn't
produce a name for the main executable object, even though it does notice the
mapping.
This causes noticeable unwind breakage because the main executable on Linux
contains various wrapper functions pertaining to memory allocation and locking,
such as
moz_xmalloc, moz_xcalloc, moz_xrealloc
mozilla::detail::MutexImpl::lock, mozilla::detail::MutexImpl::unlock
and is generally observable on x86_64-Linux as unwinding failures out of
functions with addresses around 0x40xxxx, since that's the traditional load
address for the main executable.
This patch modifies the Linux implementation of GetInfoForSelf() so as to
harvest the main executable's name from /proc/self/maps. This is then added
into the information acquired from dl_iterate_phdr. As a result
GetInfoForSelf() does correctly report the executable name, so LUL reads Dwarf
unwind info from it, and the abovementioned unwinding failures disappear.
Attachment #8856837 -
Flags: review?(n.nethercote)
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → jseward
Status: NEW → ASSIGNED
Assignee | ||
Updated•8 years ago
|
Attachment #8855801 -
Attachment is obsolete: true
![]() |
||
Comment 3•8 years ago
|
||
Comment on attachment 8856837 [details] [diff] [review]
Make LUL read CFI from the main executable on x86_64-Linux
Review of attachment 8856837 [details] [diff] [review]:
-----------------------------------------------------------------
::: tools/profiler/core/shared-libraries-linux.cc
@@ +26,5 @@
>
> // There are three different configuration cases:
> //
> // (1) GP_OS_linux
> +// Use dl_iterate_phdr for almost everything and /proc/self/maps to
/proc/self/exe as well?
@@ +143,5 @@
> + // address of its executable section (exeExeAddr) in the running image.
> + char exeName[PATH_MAX];
> + memset(exeName, 0, sizeof(exeName));
> +
> + ssize_t exeNameLen = readlink("/proc/self/exe", exeName, sizeof(exeName)-1);
Nit: spaces around '-'.
@@ +260,5 @@
> + SharedLibrary& lib = info.GetMutableEntry(i);
> + if (lib.GetStart() == exeExeAddr && lib.GetNativeDebugPath() == "") {
> + nsAutoString exeNameStr;
> + mozilla::Unused
> + << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(
'<<' on preceding line.
Attachment #8856837 -
Flags: review?(n.nethercote) → review+
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fef30348e68c
Make LUL read CFI from the main executable on x86_64-Linux. r=n.nethercote.
Comment 5•8 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in
before you can comment on or make changes to this bug.
Description
•