Skip to content

Commit

Permalink
Provide less cryptic error for missing systemlib sections (#9566)
Browse files Browse the repository at this point in the history
Summary:
If a new extension systemlib isn't wired up with the build system, its unit emitters and decls won't be embedded in the HHVM binary, causing a cryptic crash when trying to run Hack code ("Invalid varint value: too few bytes."). One then has to fire up a debugger to determine what systemlib is missing.

Instead, raise a more informative error if a specific systemlib was not found in the binary.

Split from #9564.

Pull Request resolved: #9566

Reviewed By: ricklavoie

Differential Revision: D67874442

fbshipit-source-id: 876fe61ff08fd05a311659a44c2b0a19ea878f94
  • Loading branch information
mszabo-wikia authored and facebook-github-bot committed Jan 7, 2025
1 parent b3ad3f1 commit 2412906
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hphp/runtime/vm/runtime-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "hphp/zend/zend-string.h"
#include "unit-emitter.h"

#include <stdexcept>
#include <folly/Likely.h>
#include <folly/Range.h>

Expand Down Expand Up @@ -259,6 +260,10 @@ Unit* get_systemlib(const std::string& path, const Extension* extension) {

auto buffer = get_embedded_section(path+".ue");

if (buffer.empty()) {
throw std::invalid_argument("Missing systemlib unit emitter for path: " + path);
}

UnitEmitterSerdeWrapper uew;
BlobDecoder decoder(buffer.data(), buffer.size());
uew.serde(decoder, extension);
Expand Down

0 comments on commit 2412906

Please sign in to comment.