From 925986ab34be65862b84d846b493f377aabcfc2c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 13 Feb 2024 23:12:08 -0800 Subject: [PATCH] Work around stack overflow with LLVM 18 This bisects to https://github.com/rust-lang/rust/pull/120055. Running tests/exhaustive.rs (target/release/deps/exhaustive-e2f6c3a78f65e6a2) running 1 test thread 'test' has overflowed its stack fatal runtime error: stack overflow error: test failed, to rerun pass `--test exhaustive` Caused by: process didn't exit successfully: `target/release/deps/exhaustive-e2f6c3a78f65e6a2` (signal: 6, SIGABRT: process abort signal) --- tests/exhaustive.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/exhaustive.rs b/tests/exhaustive.rs index 4051061..f2caf80 100644 --- a/tests/exhaustive.rs +++ b/tests/exhaustive.rs @@ -7,6 +7,7 @@ use clang_ast::{Id, Kind, SourceLocation, SourceRange}; use serde::de::IgnoredAny; use serde_derive::Deserialize; +use std::thread::Builder as ThreadBuilder; pub type Node = clang_ast::Node; @@ -4135,8 +4136,19 @@ fn default_true() -> bool { #[rustversion::since(2023-04-29)] const _: [(); std::mem::size_of::()] = [(); 1472]; +fn with_much_stack(test: impl FnOnce() + Send + 'static) { + ThreadBuilder::new() + .stack_size(4 * 1024 * 1024) + .spawn(test) + .unwrap() + .join() + .unwrap(); +} + #[test] fn test() { - let json = clang_ast_test_suite::cxx_ast_json(); - let _: Node = serde_json::from_slice(&json).unwrap(); + with_much_stack(|| { + let json = clang_ast_test_suite::cxx_ast_json(); + let _: Node = serde_json::from_slice(&json).unwrap(); + }); }