Skip to content

Commit

Permalink
Work around stack overflow with LLVM 18
Browse files Browse the repository at this point in the history
This bisects to rust-lang/rust#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)
  • Loading branch information
dtolnay committed Feb 14, 2024
1 parent e7b203f commit 925986a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Clang>;

Expand Down Expand Up @@ -4135,8 +4136,19 @@ fn default_true() -> bool {
#[rustversion::since(2023-04-29)]
const _: [(); std::mem::size_of::<Node>()] = [(); 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();
});
}

0 comments on commit 925986a

Please sign in to comment.