From 4708608bf77eba10fdc284e87d01e4955709a1b5 Mon Sep 17 00:00:00 2001 From: zrlk Date: Fri, 6 Oct 2023 18:45:01 -0400 Subject: [PATCH] fix(verifier): request larger stack size for new solver (#5883) In the future we can look at doing a smarter job lowering to datalog (e.g. not adding every goal into the same giant Horn clause, which was causing souffle to bump up against the stack). For now, just asking for a larger stack allows all the Go tests to pass; tested this by running them with the flag fixed to true. --- kythe/cxx/verifier/verifier_main.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/kythe/cxx/verifier/verifier_main.cc b/kythe/cxx/verifier/verifier_main.cc index 98ad7ca7a7..3966f44266 100644 --- a/kythe/cxx/verifier/verifier_main.cc +++ b/kythe/cxx/verifier/verifier_main.cc @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -69,6 +70,11 @@ ABSL_FLAG(bool, use_fast_solver, false, ABSL_FLAG(bool, print_timing_information, false, "Print timing information for profiling."); +namespace { +// The fast solver needs extra stack space for modest programs. +constexpr rlim_t kSolverStack = 64L * 1024L * 1024L; +} // namespace + int main(int argc, char** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; kythe::InitializeProgram(argv[0]); @@ -139,6 +145,23 @@ invocation and rule syntax. v.UseFastSolver(absl::GetFlag(FLAGS_use_fast_solver)); + if (absl::GetFlag(FLAGS_use_fast_solver)) { + struct rlimit rl; + int r = getrlimit(RLIMIT_STACK, &rl); + if (r != 0) { + perror("failed getting solver stack size"); + return 1; + } + if (rl.rlim_cur < kSolverStack) { + rl.rlim_cur = kSolverStack; + r = setrlimit(RLIMIT_STACK, &rl); + if (r != 0) { + perror("failed increasing solver stack size"); + return 1; + } + } + } + std::string dbname = "database"; size_t facts = 0; auto start_read_time = absl::Now();