On 2024-10-30 7:16 a.m., Yash.Shinde@windriver.com wrote:
From: Yash Shinde <Yash.Shinde@windriver.com>

For some Rust crates, like building p384 in DEBUG mode, a SIGSEGV
is encountered as follows:

     note: rustc unexpectedly overflowed its stack! this is a bug
     note: maximum backtrace depth reached, frames may have been lost
     note: we would appreciate a report at https://github.com/rust-lang/rust
     note: backtrace dumped due to SIGSEGV! resuming signal
     error: could not compile `p384` (lib)

WARNING: Backtrace (BB generated script):
        #1: oe_cargo_build, /home/poky/build/tmp/work/core2-32-wrs-linux/cargo/1.79.0/temp/run.do_compile.3262358, line 193
        #2: cargo_do_compile, /home/poky/build/tmp/work/core2-32-wrs-linux/cargo/1.79.0/temp/run.do_compile.3262358, line 165
        #3: do_compile, /home/poky/build/tmp/work/core2-32-wrs-linux/cargo/1.79.0/temp/run.do_compile.3262358, line 160
        #4: main, /home/poky/build/tmp/work/core2-32-wrs-linux/cargo/1.79.0/temp/run.do_compile.3262358, line 206

Setting RUST_MIN_STACK to 8MB conditionally for DEBUG builds only handles
the stack overflow and SIGSEGV.

s/to 8MB/from 2MB to 8MB/

Best to explain what the current default value in your commit log in case the rust devs increase the limit some day.

From:
rust.git on  🦀 v1.80.0
❯ grep -C 1 DEFAULT_MIN_ST library/std/src/sys/pal/unix/thread.rs
#[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))]
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
#[cfg(target_os = "l4re")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
#[cfg(target_os = "vxworks")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 256 * 1024;
#[cfg(target_os = "espidf")]
pub const DEFAULT_MIN_STACK_SIZE: usize = 0; // 0 indicates that the stack size configured in the ESP-IDF menuconfig system should be used


References: https://github.com/esp-rs/rust/issues/214
            https://github.com/rust-lang/rust/issues/122357
            https://github.com/rust-lang/rust/pull/122847#issue-2201254359
            https://github.com/rust-lang/rust/pull/122847/commits
Is there an issue open for the p384 crate to reconsider their stack abuse?

If so, please include that link. If not, create one and link that.


Thanks Yashe,

../Randy



Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
---
 meta/recipes-devtools/rust/cargo_1.79.0.bb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/meta/recipes-devtools/rust/cargo_1.79.0.bb b/meta/recipes-devtools/rust/cargo_1.79.0.bb
index 123032cdf7..4917b25c0c 100644
--- a/meta/recipes-devtools/rust/cargo_1.79.0.bb
+++ b/meta/recipes-devtools/rust/cargo_1.79.0.bb
@@ -37,6 +37,9 @@ do_cargo_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER"
 
 do_compile:prepend () {
 	export RUSTC_BOOTSTRAP="1"
+	if [ "${DEBUG_BUILD}" = "1" ]; then
+		export RUST_MIN_STACK=8388608
+	fi
 }
 
 do_install () {


-- 
# Randy MacLeod
# Wind River Linux