From d7b8628f39f2a7e09902cfedf130d3733a48167f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Szab=C3=B3?= Date: Mon, 6 Jan 2025 04:00:40 +0100 Subject: [PATCH] Provide less cryptic error for missing systemlib sections 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. --- 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);