Skip to content

Commit

Permalink
Cherry pick PR youtube#3939: Print an error message and return instea…
Browse files Browse the repository at this point in the history
…d of crash (youtube#3954)

Refer to the original PR: youtube#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 <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and yuying-y authored Aug 8, 2024
1 parent 06a21b3 commit dd5cf56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion starboard/elf_loader/exported_symbols.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,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;
}

Expand Down
1 change: 1 addition & 0 deletions starboard/elf_loader/exported_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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:
Expand Down

0 comments on commit dd5cf56

Please sign in to comment.