From 2412906efe33308f2bc5817d4a34837b3f836f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Tue, 7 Jan 2025 09:56:20 -0800 Subject: [PATCH] Provide less cryptic error for missing systemlib sections (#9566) 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 https://github.com/facebook/hhvm/pull/9564. Pull Request resolved: https://github.com/facebook/hhvm/pull/9566 Reviewed By: ricklavoie Differential Revision: D67874442 fbshipit-source-id: 876fe61ff08fd05a311659a44c2b0a19ea878f94 --- hphp/runtime/vm/runtime-compiler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hphp/runtime/vm/runtime-compiler.cpp b/hphp/runtime/vm/runtime-compiler.cpp index 39e570f238b6c0..a9d3d5b9df3a43 100644 --- a/hphp/runtime/vm/runtime-compiler.cpp +++ b/hphp/runtime/vm/runtime-compiler.cpp @@ -44,6 +44,7 @@ #include "hphp/zend/zend-string.h" #include "unit-emitter.h" +#include #include #include @@ -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);