From b3fd62d86ef13f671c7733b6e496f155b2f8500e Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:43:01 -0700 Subject: [PATCH] Cherry pick PR #3939: Print an error message and return instead of crash (#3953) Refer to the original PR: https://github.com/youtube/cobalt/pull/3939 When the address of a symbol couldn't be found, the app should return instead of crash. The address is validated by the caller, which returns false if address is NULL. Eventually the loader gets the error message, and reverts back to the previous good image. b/357947368 Change-Id: I74b9aa600c281a74ef817af0cd97f0cda4ab91cd Co-authored-by: yuying-y <78829091+yuying-y@users.noreply.github.com> --- starboard/elf_loader/exported_symbols.cc | 4 +++- starboard/elf_loader/exported_symbols.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index ac3794103b0961..3402e01b188ad5 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -482,7 +482,9 @@ const void* ExportedSymbols::Lookup(const char* name) { const void* address = map_[name]; // Any symbol that is not registered as part of the Starboard API in the // constructor of this class is a leak, and is an error. - SB_CHECK(address) << "Failed to retrieve the address of '" << name << "'."; + if (!address) { + SB_LOG(ERROR) << "Failed to retrieve the address of '" << name << "'."; + } return address; } diff --git a/starboard/elf_loader/exported_symbols.h b/starboard/elf_loader/exported_symbols.h index d385e1dcd50f7a..62e9b59f32a965 100644 --- a/starboard/elf_loader/exported_symbols.h +++ b/starboard/elf_loader/exported_symbols.h @@ -33,6 +33,7 @@ namespace elf_loader { class ExportedSymbols { public: ExportedSymbols(); + // Returns the address of the symbol |name|. If it's not found, returns NULL. const void* Lookup(const char* name); private: