Skip to content

Commit

Permalink
Bug 1935437 - Check in case libName could be nullptr before passing i…
Browse files Browse the repository at this point in the history
…t inside the std::string constructor in LoadedLibraryInfo constructor r=profiler-reviewers,florian

Before the shared-libraries code deduplication, we were using nsCString for the
`LoadedLibraryInfo::mName`. After the deduplication we started to use
`std::string`.

Before, it was fine to pass nullptr as a parameter to nsCString as it could
easily handle it and act as if it's an empty string. But it's an undefined
behavior on `std::string`. And passing a nullptr actively crashes Firefox when
there is a BHR hang detected (as it uses the shared libraries code).

So now, instead of directly passing `dl_info->dlpi_name` inside `std::string`,
I'm checking if it's a nullptr or not, and if so I'm passing an empty string
so we don't crash there.

Differential Revision: https://phabricator.services.mozilla.com/D231926

UltraBlame original commit: 2cb187c7d3f15302a7c2665b10157f50155cdbf1
  • Loading branch information
marco-c committed Dec 13, 2024
1 parent fd66a9b commit 6e69b90
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions mozglue/baseprofiler/core/shared-libraries-linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3607,17 +3607,32 @@ end
;
}
}
const
char
*
libName
=
dl_info
-
>
dlpi_name
?
dl_info
-
>
dlpi_name
:
"
"
;
libInfoList
-
>
push_back
(
LoadedLibraryInfo
(
dl_info
-
>
dlpi_name
libName
baseAddress
firstMappingStart
lastMappingEnd
Expand Down

0 comments on commit 6e69b90

Please sign in to comment.