about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-27 19:40:59 +0000
committerbors <bors@rust-lang.org>2022-07-27 19:40:59 +0000
commit40875353a59ea0be83c711e2223f20e6fe283a47 (patch)
tree7254566a5e55aff7520693b1569ea2b9453aecb8
parent9a1ec451d3c8c6bed062ee002b5c613d64ca1ecd (diff)
parentf83738e1d993d84c1607fcabdf9f41ab00f83d55 (diff)
downloadrust-40875353a59ea0be83c711e2223f20e6fe283a47.tar.gz
rust-40875353a59ea0be83c711e2223f20e6fe283a47.zip
Auto merge of #12891 - brennanvincent:expander_stack, r=lnicola
Use large stack on expander thread

I have verified that this fixes #12884 for me.

Hat tip to `@bjorn3` for identifying the cause of the issue.
-rw-r--r--crates/proc-macro-srv/src/lib.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs
index 4b1858b8ed8..4c205b9cada 100644
--- a/crates/proc-macro-srv/src/lib.rs
+++ b/crates/proc-macro-srv/src/lib.rs
@@ -39,6 +39,8 @@ pub(crate) struct ProcMacroSrv {
     expanders: HashMap<(PathBuf, SystemTime), dylib::Expander>,
 }
 
+const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
+
 impl ProcMacroSrv {
     pub fn expand(&mut self, task: ExpandMacro) -> Result<FlatTree, PanicMessage> {
         let expander = self.expander(task.lib.as_ref()).map_err(|err| {
@@ -66,13 +68,18 @@ impl ProcMacroSrv {
         // FIXME: replace this with std's scoped threads once they stabilize
         // (then remove dependency on crossbeam)
         let result = crossbeam::scope(|s| {
-            let res = s
+            let res = match s
+                .builder()
+                .stack_size(EXPANDER_STACK_SIZE)
+                .name(task.macro_name.clone())
                 .spawn(|_| {
                     expander
                         .expand(&task.macro_name, &macro_body, attributes.as_ref())
                         .map(|it| FlatTree::new(&it))
-                })
-                .join();
+                }) {
+                Ok(handle) => handle.join(),
+                Err(e) => std::panic::resume_unwind(Box::new(e)),
+            };
 
             match res {
                 Ok(res) => res,