fix: close the VBS-side gaps noted on Void/Library#61
This commit is contained in:
1 parent
4f581d1b51
commit
4d51331777
13 files changed
+158
-14
No files matched your search
@@ -326,6 +326,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 116 (CLion Plugin Repository)**: `vbs ide plugin --editor clion` emits a JetBrains plugin skeleton (`plugin.xml` with Tools-menu actions, `build.gradle.kts`, a Kotlin action file, README); assets published to the new [Void/VbsCLion](https://git.faumaray.com/Void/VbsCLion) repository and confirmed via the Gitea API. All three editor plugin repositories now exist.
|
||||
|
||||
- **Wave 117 (#61 VBS-Side Gaps)**: three gaps noted on Void/Library#61 are fixed in VBS - (1) `ProcessRequest::descendant_grace` bounds post-leader orphan supervision and the group is fully reaped so test runs cannot hang on escaped grandchildren; (2) installer archives are signed over a short canonical `vbs-installer-v1` digest message (streamed SHA-256, `.msg` written) instead of the archive bytes, removing the 16 MiB one-shot crypto limit; (3) `.native_builder({...})` options are passed to a dependency's `build.cpp` as `VBS_DEP_OPTION_<NAME>` (plus `VBS_DEP_NAME`), readable through the new SDK `Void::Build::dependency_option()`.
|
||||
|
||||
## Remaining future scope
|
||||
|
||||
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
||||
|
||||
@@ -1635,6 +1635,22 @@ vbs ide plugin --project <proj> --build-dir <build> --editor vscode --output <di
|
||||
- Published to the new [Void/VbsZed](https://git.faumaray.com/Void/VbsZed) repository
|
||||
(`extension.toml`, `tasks.json`, `README.md`); contents confirmed through the Gitea API.
|
||||
|
||||
## #61 VBS-Side Gaps Fixed (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- **Orphan reaping**: `ProcessRequest::descendant_grace` (default 5 s, 0 = wait forever) bounds
|
||||
the post-leader group drain, after which the group is terminated and reaped until `waitpid`
|
||||
reports no children. `process_supervisor_exec_failure_and_early_leader_grandchild_kill` gained a
|
||||
no-timeout case: it returns in well under 5 s and the escaped grandchild never writes its
|
||||
sentinel (**passed**, 1.10 s).
|
||||
- **Signing size limit**: the installer signs `vbs-installer-v1\n<sha256>\n` (the archive digest is
|
||||
streamed with `sha256_file_hex`), writes `<archive>.msg`, and never loads the archive into
|
||||
memory; the install test verifies the signature over the message and that a tampered digest
|
||||
fails (**passed**, 6.83 s).
|
||||
- **native_builder options**: `FrontendOptions::extra_environment` is applied to every descriptor
|
||||
process, the native provider forwards `VBS_DEP_OPTION_<KEY>`/`VBS_DEP_NAME`, and
|
||||
`Void::Build::dependency_option(name)` reads them; the native-subproject fixture now throws
|
||||
unless it receives `SUB_MATH_ENABLED=yes` (**passed**, 4.16 s).
|
||||
|
||||
## Limits and Unrun Checks
|
||||
|
||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||
|
||||
@@ -319,6 +319,10 @@ class Dependency {
|
||||
std::size_t index_;
|
||||
};
|
||||
|
||||
// Value of a `.native_builder({...})` option passed by the consuming project to this
|
||||
// dependency's build.cpp (exposed as VBS_DEP_OPTION_<NAME>), or an empty string when unset.
|
||||
[[nodiscard]] std::string dependency_option(std::string_view name);
|
||||
|
||||
class Project {
|
||||
public:
|
||||
explicit Project(ProfileContext context);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -23,6 +24,8 @@ struct FrontendOptions {
|
||||
std::filesystem::path sdk_source_dir; // Fallback source dir if sdk_library_path absent
|
||||
std::vector<std::filesystem::path> extra_build_sources; // Explicit --build-source inputs
|
||||
std::optional<std::filesystem::path> host_compiler;
|
||||
// Extra environment for the descriptor process (e.g. dependency options for a native dep).
|
||||
std::map<std::string, std::string, std::less<>> extra_environment;
|
||||
std::chrono::milliseconds eval_timeout{std::chrono::seconds{30}};
|
||||
};
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ struct InstallOptions {
|
||||
std::string archive_format{"tar"};
|
||||
std::string package_description; // Used by package metadata (deb).
|
||||
std::string maintainer; // Used by package metadata (deb).
|
||||
// Optional Ed25519 seed file: signs the generated archive and writes
|
||||
// `<archive>.sha256`, `<archive>.sig` and `<archive>.pub`.
|
||||
// Optional Ed25519 seed file: signs a canonical `vbs-installer-v1` digest message over the
|
||||
// generated archive and writes `<archive>.sha256`, `<archive>.sig`, `<archive>.pub` and
|
||||
// `<archive>.msg` (the exact signed message).
|
||||
std::optional<std::filesystem::path> signing_seed_path;
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ struct ProcessRequest {
|
||||
std::size_t max_stderr_bytes{8ULL * 1024ULL * 1024ULL};
|
||||
bool fail_on_overflow{false};
|
||||
std::chrono::milliseconds timeout{0}; // 0 = no timeout
|
||||
// How long descendants of an exited leader may keep the process group alive before it is
|
||||
// terminated and reaped. 0 waits indefinitely.
|
||||
std::chrono::milliseconds descendant_grace{5000};
|
||||
std::chrono::milliseconds kill_grace{200};
|
||||
bool search_path{true};
|
||||
std::function<void(std::string_view)> on_stdout_chunk;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <Void/Build/Util/Json.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
@@ -567,6 +568,22 @@ std::string Profiles::to_json() const {
|
||||
'}';
|
||||
}
|
||||
|
||||
std::string dependency_option(std::string_view name) {
|
||||
std::string upper{name};
|
||||
for (char &c : upper) {
|
||||
c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
||||
}
|
||||
// Consumers pass fixed keys verbatim first, then the upper-cased convention.
|
||||
if (const char *exact = std::getenv(("VBS_DEP_OPTION_" + std::string{name}).c_str());
|
||||
exact != nullptr) {
|
||||
return exact;
|
||||
}
|
||||
if (const char *value = std::getenv(("VBS_DEP_OPTION_" + upper).c_str()); value != nullptr) {
|
||||
return value;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Profiles default_profiles() {
|
||||
Profiles result;
|
||||
result.add("debug", {"-O0", "-g"});
|
||||
|
||||
@@ -608,6 +608,9 @@ discover_profiles(const CompiledDescriptor &descriptor, const FrontendOptions &o
|
||||
req.arguments = {"--mode", "profiles", "--output", out_file.string(), "--request-id", req_id};
|
||||
req.working_directory = options.project_root;
|
||||
req.timeout = options.eval_timeout;
|
||||
for (const auto &[key, value] : options.extra_environment) {
|
||||
req.environment.set_vars[key] = value;
|
||||
}
|
||||
|
||||
auto proc = Platform::run_supervised(req);
|
||||
auto cleanup = [&] { std::filesystem::remove(out_file, ec); };
|
||||
@@ -735,6 +738,9 @@ evaluate_project(const CompiledDescriptor &descriptor, const ProfileContext &con
|
||||
"--context-hash", ctx_hash};
|
||||
req.working_directory = options.project_root;
|
||||
req.timeout = options.eval_timeout;
|
||||
for (const auto &[key, value] : options.extra_environment) {
|
||||
req.environment.set_vars[key] = value;
|
||||
}
|
||||
|
||||
auto proc = Platform::run_supervised(req);
|
||||
if (!proc) {
|
||||
@@ -819,6 +825,9 @@ evaluate_workspace(const CompiledDescriptor &descriptor, const FrontendOptions &
|
||||
req.arguments = {"--mode", "workspace", "--output", out_file.string(), "--request-id", req_id};
|
||||
req.working_directory = options.project_root;
|
||||
req.timeout = options.eval_timeout;
|
||||
for (const auto &[key, value] : options.extra_environment) {
|
||||
req.environment.set_vars[key] = value;
|
||||
}
|
||||
|
||||
auto proc = Platform::run_supervised(req);
|
||||
auto cleanup = [&] { std::filesystem::remove(out_file, ec); };
|
||||
|
||||
@@ -496,6 +496,11 @@ write_deb_package(const std::filesystem::path &output, const InstallOptions &opt
|
||||
return Platform::atomic_write_file(output, deb, true);
|
||||
}
|
||||
|
||||
// Canonical short message signed for installer archives (independent of archive size).
|
||||
std::string installer_signing_message(std::string_view archive_sha256) {
|
||||
return "vbs-installer-v1\n" + std::string{archive_sha256} + "\n";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Void::Result::Result<InstallReport, Void::Result::Error>
|
||||
@@ -904,13 +909,15 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
}
|
||||
report.archive_path = *options.archive_path;
|
||||
|
||||
// Optional detached signature and checksums over the final archive bytes.
|
||||
// Optional detached signature and checksums over the final archive. The signed message
|
||||
// is a short canonical digest statement, not the archive bytes, so archives of any size
|
||||
// stay within the crypto one-shot limit.
|
||||
if (options.signing_seed_path) {
|
||||
auto bytes = Void::FileSystem::read_file(*options.archive_path);
|
||||
if (!bytes) {
|
||||
return std::unexpected{bytes.error()};
|
||||
auto digest = Util::sha256_file_hex(*options.archive_path);
|
||||
if (!digest) {
|
||||
return std::unexpected{digest.error()};
|
||||
}
|
||||
report.archive_sha256 = Util::sha256_hex(*bytes);
|
||||
report.archive_sha256 = *digest;
|
||||
report.checksum_path = options.archive_path->string() + ".sha256";
|
||||
if (auto written = Platform::atomic_write_file(
|
||||
*report.checksum_path,
|
||||
@@ -920,8 +927,10 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
|
||||
const std::string canonical_message = installer_signing_message(report.archive_sha256);
|
||||
auto signature = Provenance::sign_message(
|
||||
std::as_bytes(std::span<const char>{bytes->data(), bytes->size()}),
|
||||
std::as_bytes(std::span<const char>{canonical_message.data(),
|
||||
canonical_message.size()}),
|
||||
*options.signing_seed_path);
|
||||
if (!signature) {
|
||||
return std::unexpected{signature.error()};
|
||||
@@ -942,6 +951,11 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
if (auto written = Platform::atomic_write_file(
|
||||
options.archive_path->string() + ".msg", canonical_message, true);
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
}
|
||||
}
|
||||
return report;
|
||||
|
||||
@@ -158,8 +158,11 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
|
||||
// drains, times out, or is cancelled, then escalate via SIGTERM -> kill_grace -> SIGKILL.
|
||||
bool group_timed_out = comm->timed_out;
|
||||
bool group_cancelled = comm->cancelled;
|
||||
bool descendants_terminated = false;
|
||||
const pid_t pgid = static_cast<pid_t>(child->pgid());
|
||||
if (!group_timed_out && !group_cancelled && !comm->overflowed) {
|
||||
const auto descendant_deadline =
|
||||
std::chrono::steady_clock::now() + request.descendant_grace;
|
||||
while (child->process_group_alive()) {
|
||||
// Reap any adopted descendants in this process group (subreaper) so zombies clear.
|
||||
int wstatus = 0;
|
||||
@@ -172,18 +175,40 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
|
||||
group_cancelled = true;
|
||||
break;
|
||||
}
|
||||
if (has_timeout && std::chrono::steady_clock::now() >= deadline) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (has_timeout && now >= deadline) {
|
||||
group_timed_out = true;
|
||||
break;
|
||||
}
|
||||
// Orphans must not keep the supervisor (or a test run) alive forever.
|
||||
if (request.descendant_grace.count() > 0 && now >= descendant_deadline) {
|
||||
descendants_terminated = true;
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{10});
|
||||
}
|
||||
}
|
||||
|
||||
if (group_cancelled || group_timed_out || comm->overflowed || child->process_group_alive()) {
|
||||
if (group_cancelled || group_timed_out || descendants_terminated || comm->overflowed ||
|
||||
child->process_group_alive()) {
|
||||
(void)child->terminate(request.kill_grace);
|
||||
// Reap the whole group until it is really gone (bounded), so no zombie or orphan is
|
||||
// left behind after test supervision.
|
||||
const auto reap_deadline =
|
||||
std::chrono::steady_clock::now() + request.kill_grace + std::chrono::seconds{2};
|
||||
int wstatus = 0;
|
||||
while (pgid > 0 && ::waitpid(-pgid, &wstatus, WNOHANG) > 0) {
|
||||
while (pgid > 0) {
|
||||
const pid_t reaped = ::waitpid(-pgid, &wstatus, WNOHANG);
|
||||
if (reaped < 0) { // ECHILD: no descendants left.
|
||||
break;
|
||||
}
|
||||
if (reaped == 0) {
|
||||
if (std::chrono::steady_clock::now() >= reap_deadline) {
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{5});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1065,6 +1065,11 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
||||
if (request.sdk_library_path) {
|
||||
fopts.sdk_library_path = *request.sdk_library_path;
|
||||
}
|
||||
// Pass the consumer's `.native_builder({...})` options to the dependency's build.cpp.
|
||||
fopts.extra_environment["VBS_DEP_NAME"] = request.dependency.name;
|
||||
for (const auto &[key, value] : request.dependency.options) {
|
||||
fopts.extra_environment["VBS_DEP_OPTION_" + key] = cmake_option_value(value);
|
||||
}
|
||||
auto compiled = Config::compile_descriptor(fopts);
|
||||
if (!compiled) {
|
||||
return std::unexpected{compiled.error()};
|
||||
|
||||
@@ -112,6 +112,30 @@ VOID_TEST(CoreEngineTests, process_supervisor_exec_failure_and_early_leader_gran
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{300});
|
||||
Void::Testing::expect(!std::filesystem::exists(sentinel));
|
||||
}
|
||||
|
||||
// 4. Without a request timeout, orphaned descendants are reaped after descendant_grace so
|
||||
// test supervision never hangs (and the escaped grandchild is killed).
|
||||
{
|
||||
Void::FileSystem::TempDir tmp{"vbs_proc_"};
|
||||
const auto sentinel = tmp / "orphan_escaped.txt";
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = "/bin/sh";
|
||||
req.arguments = {"-c", "sh -c 'trap \"\" TERM; sleep 1.5; echo escaped > \"" +
|
||||
sentinel.string() + "\"' >/dev/null 2>&1 & exit 0"};
|
||||
req.descendant_grace = std::chrono::milliseconds{150};
|
||||
req.kill_grace = std::chrono::milliseconds{80};
|
||||
const auto started = std::chrono::steady_clock::now();
|
||||
auto res = Platform::run_supervised(req);
|
||||
const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - started);
|
||||
Void::Testing::expect(res.has_value());
|
||||
if (res) {
|
||||
Void::Testing::expect(res->succeeded());
|
||||
}
|
||||
Void::Testing::expect(elapsed < std::chrono::seconds{5});
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{300});
|
||||
Void::Testing::expect(!std::filesystem::exists(sentinel));
|
||||
}
|
||||
}
|
||||
|
||||
VOID_TEST(CoreEngineTests, profile_inheritance_and_cycle_rejection) {
|
||||
|
||||
+24
-3
@@ -1038,17 +1038,31 @@ void build(Void::Build::Project &p) {
|
||||
auto signature_text = Void::FileSystem::read_file(signed_archive.string() + ".sig");
|
||||
auto public_key_text = Void::FileSystem::read_file(signed_archive.string() + ".pub");
|
||||
auto checksum_text = Void::FileSystem::read_file(signed_archive.string() + ".sha256");
|
||||
auto message_text = Void::FileSystem::read_file(signed_archive.string() + ".msg");
|
||||
Void::Testing::require(archive_bytes.has_value() && signature_text.has_value() &&
|
||||
public_key_text.has_value() && checksum_text.has_value());
|
||||
public_key_text.has_value() && checksum_text.has_value() &&
|
||||
message_text.has_value());
|
||||
Void::Testing::expect_eq(signature_text->size(), std::size_t{129});
|
||||
Void::Testing::expect_eq(public_key_text->size(), std::size_t{65});
|
||||
Void::Testing::expect(checksum_text->starts_with(Util::sha256_hex(*archive_bytes)));
|
||||
// The signed message is the short canonical digest statement, not the archive bytes.
|
||||
Void::Testing::expect(message_text->starts_with("vbs-installer-v1\n"));
|
||||
Void::Testing::expect(message_text->size() < 128);
|
||||
auto verified = Provenance::verify_message(
|
||||
std::as_bytes(std::span<const char>{archive_bytes->data(), archive_bytes->size()}),
|
||||
std::as_bytes(std::span<const char>{message_text->data(), message_text->size()}),
|
||||
std::string_view{*signature_text}.substr(0, 128),
|
||||
std::string_view{*public_key_text}.substr(0, 64));
|
||||
Void::Testing::require(verified.has_value());
|
||||
Void::Testing::expect(*verified);
|
||||
// A tampered digest must not verify.
|
||||
std::string tampered = *message_text;
|
||||
tampered[tampered.size() - 2] = tampered[tampered.size() - 2] == '0' ? '1' : '0';
|
||||
auto tampered_result = Provenance::verify_message(
|
||||
std::as_bytes(std::span<const char>{tampered.data(), tampered.size()}),
|
||||
std::string_view{*signature_text}.substr(0, 128),
|
||||
std::string_view{*public_key_text}.substr(0, 64));
|
||||
Void::Testing::require(tampered_result.has_value());
|
||||
Void::Testing::expect(!*tampered_result);
|
||||
} else {
|
||||
// Without an Ed25519 backend signing must fail closed, never silently skip.
|
||||
Void::Testing::expect(sign_res.has_value() && !sign_res->succeeded());
|
||||
@@ -2095,7 +2109,14 @@ VOID_TEST(FullV1Tests, native_vbs_subproject_dependency_builds_without_cmake) {
|
||||
// Pure `build.cpp` library dependency (NO CMakeLists.txt!).
|
||||
const auto dep_dir = tmp / "sub_math_dep";
|
||||
write_file(dep_dir / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
void build(Void::Build::Project &p) {
|
||||
// The consumer's .native_builder({...}) options reach this description.
|
||||
const std::string enabled = Void::Build::dependency_option("SUB_MATH_ENABLED");
|
||||
if (enabled != "yes") {
|
||||
throw std::runtime_error("SUB_MATH_ENABLED must be yes, got '" + enabled + "'");
|
||||
}
|
||||
auto lib = p.static_library("sub_math");
|
||||
lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"src/math.cpp"})
|
||||
@@ -2113,7 +2134,7 @@ void build(Void::Build::Project &p) {
|
||||
"void build(Void::Build::Project &p) {\n"
|
||||
" auto dep = p.dependency(\"math\").path(\"" +
|
||||
dep_dir.string() +
|
||||
"\").native_builder();\n"
|
||||
"\").native_builder({{\"SUB_MATH_ENABLED\", \"yes\"}});\n"
|
||||
" p.test(\"consumer_test\")\n"
|
||||
" .cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
||||
" .sources({\"tests/main.cpp\"})\n"
|
||||
|
||||
Reference in new issue
Block a user