la10736 / temp_testdir

Simple temp dir manager for testing
Apache License 2.0
2 stars 3 forks source link

`cargo test` randomly hangs #6

Open siretart opened 1 week ago

siretart commented 1 week ago

Invoke the tests like this and the invocation hangs:

$ TMPDIR=/nonexistent cargo test 
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (target/debug/deps/temp_testdir-76f554e78ab30668)

running 8 tests
test test::default_temp_should_destroy_also_content ... FAILED
test test::should_not_leave_a_dangling_empty_directory ... ok
test test::default_tempdir_should_create_a_directory ... ok
test test::tempdir_permanent_should_do_not_remove_dir ... ok
test test::should_resolve_rstest_temp_dir_root_name_in_env ... ok
test test::should_resolve_root_in_env ... ok
test test::default_tempdir_should_destroy_directory_after_go_out_of_scope ... ok
C-c C-c
la10736 commented 1 week ago

I guess you have non permission to create this folder.... I know that the should manage this kind of corner case but I wrote this crate just to write rstest's tests... I don't think I'll manage this kind of corner cases.

siretart commented 1 week ago

I apologize, I think I misdiagnosed the issue. You are right, when setting it to an non-existing directory that I don't have permissions to create, I am seeing this error:

siretart@x1:~/packages/rust/debcargo-conf/build/temp-testdir $ TMPDIR=/nonexistent cargo test  --all-features
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (target/debug/deps/temp_testdir-76f554e78ab30668)

running 8 tests
test test::default_tempdir_should_create_a_directory ... FAILED
test test::default_tempdir_should_destroy_directory_after_go_out_of_scope ... FAILED
test test::should_not_leave_a_dangling_empty_directory ... ok
test test::default_temp_should_destroy_also_content ... ok
test test::should_resolve_rstest_temp_dir_root_name_in_env ... ok
test test::tempdir_permanent_should_do_not_remove_dir ... ok
test test::should_resolve_root_in_env ... ok
test test::two_temp_dir_should_have_different_path ... ok

failures:

---- test::default_tempdir_should_create_a_directory stdout ----
thread 'test::default_tempdir_should_create_a_directory' panicked at src/lib.rs:64:46:
Should create the parent dir: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test::default_tempdir_should_destroy_directory_after_go_out_of_scope stdout ----
thread 'test::default_tempdir_should_destroy_directory_after_go_out_of_scope' panicked at src/lib.rs:64:46:
Should create the parent dir: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }

failures:
    test::default_tempdir_should_create_a_directory
    test::default_tempdir_should_destroy_directory_after_go_out_of_scope

test result: FAILED. 6 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--lib`

It'd be great if the testsuite would handle that corner case more gracefully than claiming the code was bad, but I totally understand your pov that this doesn't warrant changes to the code.

siretart commented 1 week ago

I've looked more into it and I do see random hangs even without setting TMPDIR to funny directories. I am unable to pinpoint exactly why it hangs or what triggers the hang, but it happens very reliably during the package build. I am somewhat reliably able to reproduce it when invoking the test suite like this:

while true; do cargo test --all-features; sleep 1; done

When the process was hanging, I managed to capture a stacktrace:

(gdb) thread apply all bt full

Thread 2 (Thread 0x7f336e0006c0 (LWP 1900333) "test::tempdir_p"):
#0  __GI___mkdir (path=0x7f336dfff100 "this_test_root/other_rstest_root.42101913", mode=511) at ../sysdeps/unix/sysv/linux/mkdir.c:28
        sc_ret = -2
#1  0x0000562723bb9081 in std::sys::unix::fs::{impl#18}::mkdir::{closure#0} (p=...) at library/std/src/sys/unix/fs.rs:1393
        self = <optimized out>
#2  std::sys::common::small_c_string::run_with_cstr<(), std::sys::unix::fs::{impl#18}::mkdir::{closure_env#0}> (bytes=..., f=...) at library/std/src/sys/common/small_c_string.rs:43
        s = &core::ffi::c_str::CStr []
        buf_ptr = 0x7f336dfff100
        buf = core::mem::maybe_uninit::MaybeUninit<[u8; 384]> {uninit: (), value: core::mem::manually_drop::ManuallyDrop<[u8; 384]> {value: [116, 104, 105, 115, 95, 116, 101, 115, 116, 95, 114, 111, 111, 116, 47, 111, 116, 104, 101, 114, 95, 114, 115, 116, 101, 115, 116, 95, 114, 111, 111, 116, 46, 52, 50, 49, 48, 49, 57, 49, 51, 0, 0, 64, 51, 127, 0, 0, 254, 255, 255, 255, 255, 255, 255, 191, 13, 0, 64, 51, 127, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 56, 242, 255, 109, 51, 127, 0, 0, 64, 242, 255, 109, 51, 127, 0, 0, 64, 242, 255, 109, 51, 127, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 240, 254, 255, 255, 255, 255, 255, 255, 2, 0, 0, 0, 0, 0, 0, 0, 232, 224, 193, 35, 39, 86, 0, 0, 255, 255, 255, 255, 255, 255, 255, 127, 0, 0, 0, 0, 0, 0, 0, 0, 47, 158, 85, 111, 51, 127, 0, 0, 80, 242, 255, 109, 51, 127, 0, 0, 80, 242, 255, 109, 51, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 40, 247, 255, 109, 51, 127, 0, 0, 0, 202, 154, 59, 0, 0, 0, 0...]}}
        buf = <optimized out>
        buf_ptr = <optimized out>
        s = <optimized out>
#3  std::sys::common::small_c_string::run_path_with_cstr<(), std::sys::unix::fs::{impl#18}::mkdir::{closure_env#0}> (path=..., f=...) at library/std/src/sys/common/small_c_string.rs:22
No locals.
#4  std::sys::unix::fs::DirBuilder::mkdir (self=0x7f336dfff310, p=...) at library/std/src/sys/unix/fs.rs:1393
No locals.
#5  std::fs::DirBuilder::_create (self=0x7f336dfff310, path=...) at library/std/src/fs.rs:2547
No locals.
#6  0x0000562723b41702 in std::fs::DirBuilder::create<&std::path::Path> (self=0x7f336dfff310, path=...) at /usr/src/rustc-1.75.0/library/std/src/fs.rs:2543
No locals.
#7  0x0000562723b4177c in std::fs::create_dir<&std::path::PathBuf> (path=0x7f336dfff3f8) at /usr/src/rustc-1.75.0/library/std/src/fs.rs:2246
No locals.
#8  0x0000562723b3e314 in temp_testdir::TempDir::new<std::path::PathBuf> (path=..., destroy=true) at src/lib.rs:49
        path = std::path::PathBuf {inner: std::ffi::os_str::OsString {inner: std::sys::unix::os_str::Buf {inner: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0x7f3340000db0}, _marker: core::marker::PhantomData<u8>}, cap: 41, alloc: alloc::alloc::Global}, len: 41}}}}
#9  0x0000562723b3b73a in temp_testdir::{impl#0}::default () at src/lib.rs:15
No locals.
#10 0x0000562723b35e99 in temp_testdir::test::tempdir_permanent_should_do_not_remove_dir () at src/lib.rs:124
        path = std::path::PathBuf {inner: std::ffi::os_str::OsString {inner: std::sys::unix::os_str::Buf {inner: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0x0}, _marker: core::marker::PhantomData<u8>}, cap: 0, alloc: alloc::alloc::Global}, len: 0}}}}
#11 0x0000562723b36fa7 in temp_testdir::test::tempdir_permanent_should_do_not_remove_dir::{closure#0} () at src/lib.rs:121
No locals.
#12 0x0000562723b397b6 in core::ops::function::FnOnce::call_once<temp_testdir::test::tempdir_permanent_should_do_not_remove_dir::{closure_env#0}, ()> () at /usr/src/rustc-1.75.0/library/core/src/ops/function.rs:250
No locals.
#13 0x0000562723b4a65f in core::ops::function::FnOnce::call_once<fn() -> core::result::Result<(), alloc::string::String>, ()> () at library/core/src/ops/function.rs:250
No locals.
#14 test::__rust_begin_short_backtrace<core::result::Result<(), alloc::string::String>, fn() -> core::result::Result<(), alloc::string::String>> (f=0x1ff) at library/test/src/lib.rs:628
No locals.
#15 0x0000562723b59b8e in test::types::RunnableTest::run (self=...) at library/test/src/types.rs:146
        f = 0x1ff
#16 0x0000562723b4a83f in test::run_test_in_process::{closure#0} () at library/test/src/lib.rs:651
--Type <RET> for more, q to quit, c to continue without paging--
        runnable_test = <error reading variable runnable_test (Cannot access memory at address 0x0)>
#17 core::panic::unwind_safe::{impl#23}::call_once<core::result::Result<(), alloc::string::String>, test::run_test_in_process::{closure_env#0}> (self=...) at library/core/src/panic/unwind_safe.rs:272
        _args = <optimized out>
#18 std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> (data=<optimized out>) at library/std/src/panicking.rs:552
        f = core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}> (test::run_test_in_process::{closure_env#0} {runnable_test: test::types::RunnableTest::Static(0x562723b397a0 <core::ops::function::FnOnce::call_once<temp_testdir::test::tempdir_permanent_should_do_not_remove_dir::{closure_env#0}, ()>>)})
        data = <optimized out>
        data = <optimized out>
        f = <error reading variable f (Cannot access memory at address 0x0)>
#19 std::panicking::try<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>> (f=...) at library/std/src/panicking.rs:516
        data = std::panicking::try::Data<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> {f: core::mem::manually_drop::ManuallyDrop<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>> {value: core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}> (test::run_test_in_process::{closure_env#0} {runnable_test: test::types::RunnableTest::Static(<optimized out>)})}, r: core::mem::manually_drop::ManuallyDrop<core::result::Result<(), alloc::string::String>> {value: core::result::Result<(), alloc::string::String>::Ok(<synthetic pointer>)}, p: core::mem::manually_drop::ManuallyDrop<alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>> {value: alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global> {pointer: <optimized out>, vtable: <optimized out>}}}
        data = <error reading variable data (Cannot access memory at address 0x0)>
        data_ptr = <optimized out>
#20 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> (f=<error reading variable: Cannot access memory at address 0x0>) at library/std/src/panic.rs:142
        f = core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}> (test::run_test_in_process::{closure_env#0} {runnable_test: test::types::RunnableTest::Static(0x562723b397a0 <core::ops::function::FnOnce::call_once<temp_testdir::test::tempdir_permanent_should_do_not_remove_dir::{closure_env#0}, ()>>)})
#21 test::run_test_in_process (id=..., desc=..., nocapture=<optimized out>, report_time=<optimized out>, runnable_test=..., monitor_ch=..., time_opts=...) at library/test/src/lib.rs:651
        start = core::option::Option<std::time::Instant>::None
        data = <optimized out>
#22 0x0000562723b4bdab in test::run_test::{closure#0} () at library/test/src/lib.rs:574
        strategy = test::options::RunStrategy::InProcess
        id = test::types::TestId (6)
        desc = test::types::TestDesc {name: test::types::TestName::AlignedTestName(alloc::borrow::Cow<str>::Borrowed("test::tempdir_permanent_should_do_not_remove_dir"), test::types::NamePadding::PadNone), ignore: false, ignore_message: core::option::Option<&str>::None, source_file: "src/lib.rs", start_line: 121, start_col: 8, end_line: 121, end_col: 50, should_panic: test::options::ShouldPanic::No, compile_fail: false, no_run: false, test_type: test::types::TestType::UnitTest}
        nocapture = false
        time_options = core::option::Option<test::time::TestTimeOptions>::None
        runnable_test = test::types::RunnableTest::Static(0x562723b397a0 <core::ops::function::FnOnce::call_once<temp_testdir::test::tempdir_permanent_should_do_not_remove_dir::{closure_env#0}, ()>>)
        monitor_ch = std::sync::mpsc::Sender<test::event::CompletedTest> {inner: std::sync::mpmc::Sender<test::event::CompletedTest> {flavor: std::sync::mpmc::SenderFlavor<test::event::CompletedTest>::List(std::sync::mpmc::counter::Sender<std::sync::mpmc::list::Channel<test::event::CompletedTest>> {counter: 0x562725087d00})}}
        bench_benchmarks = false
#23 test::run_test::{closure#1} () at library/test/src/lib.rs:602
        runtest2 = alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}
#24 std::sys_common::backtrace::__rust_begin_short_backtrace<test::run_test::{closure_env#1}, ()> (f=...) at library/std/src/sys_common/backtrace.rs:154
No locals.
#25 0x0000562723b568ea in std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure#0}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:529
        f = test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}
#26 core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> (self=...) at library/core/src/panic/unwind_safe.rs:272
        _args = <optimized out>
--Type <RET> for more, q to quit, c to continue without paging--
#27 std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> (data=<optimized out>) at library/std/src/panicking.rs:552
        f = core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> (std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()> {f: test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}})
        data = <optimized out>
        data = <optimized out>
        f = <optimized out>
#28 std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>> (f=...) at library/std/src/panicking.rs:516
        data = std::panicking::try::Data<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> {f: core::mem::manually_drop::ManuallyDrop<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>> {value: core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> (std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()> {f: test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}})}, r: core::mem::manually_drop::ManuallyDrop<()> {value: <synthetic pointer>}, p: core::mem::manually_drop::ManuallyDrop<alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>> {value: alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global> {pointer: 0x56272508c120, vtable: <synthetic pointer>}}}
        data = <optimized out>
        data_ptr = <optimized out>
#29 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> (f=...) at library/std/src/panic.rs:142
        f = core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> (std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()> {f: test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}})
#30 std::thread::{impl#0}::spawn_unchecked_::{closure#1}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:528
        f = test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}
        their_thread = std::thread::Thread {inner: core::pin::Pin<alloc::sync::Arc<std::thread::Inner, alloc::alloc::Global>> {pointer: alloc::sync::Arc<std::thread::Inner, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::thread::Inner>> {pointer: 0x56272508a8c0}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::thread::Inner>>, alloc: alloc::alloc::Global}}}
        output_capture = core::option::Option<alloc::sync::Arc<std::sync::mutex::Mutex<alloc::vec::Vec<u8, alloc::alloc::Global>>, alloc::alloc::Global>>::None
        f = std::thread::{impl#0}::spawn_unchecked_::MaybeDangling<test::run_test::{closure_env#1}> (core::mem::maybe_uninit::MaybeUninit<test::run_test::{closure_env#1}> {uninit: (), value: core::mem::manually_drop::ManuallyDrop<test::run_test::{closure_env#1}> {value: test::run_test::{closure_env#1} {runtest2: alloc::sync::Arc<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>> {pointer: 0x56272508c120}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::sync::mutex::Mutex<core::option::Option<test::run_test::{closure_env#0}>>>>, alloc: alloc::alloc::Global}}}})
        their_packet = alloc::sync::Arc<std::thread::Packet<()>, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::sync::ArcInner<std::thread::Packet<()>>> {pointer: 0x5627250882b0}, phantom: core::marker::PhantomData<alloc::sync::ArcInner<std::thread::Packet<()>>>, alloc: alloc::alloc::Global}
        name = <optimized out>
        f = <optimized out>
        try_result = <error reading variable try_result (Cannot access memory at address 0x0)>
#31 core::ops::function::FnOnce::call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<test::run_test::{closure_env#1}, ()>, ()> () at library/core/src/ops/function.rs:250
No locals.
#32 0x0000562723b8d8d5 in alloc::boxed::{impl#47}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> (self=..., args=<optimized out>) at library/alloc/src/boxed.rs:2007
No locals.
#33 alloc::boxed::{impl#47}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> (self=0x56272508a9e0, args=<optimized out>) at library/alloc/src/boxed.rs:2007
No locals.
#34 std::sys::unix::thread::{impl#2}::new::thread_start (main=0x56272508a9e0) at library/std/src/sys/unix/thread.rs:108
--Type <RET> for more, q to quit, c to continue without paging--
        _handler = std::sys::unix::stack_overflow::Handler {data: 0x7f336f7c8000}
#35 0x00007f336f549dab in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
        ret = <optimized out>
        pd = <optimized out>
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {139858887875312, 6392458006463388212, -272, 2, 140720370323552, 139858863456256, -6426556061115082188, -6426552997538031052}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#36 0x00007f336f5cb9f8 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
No locals.
Recursive internal problem.
la10736 commented 1 week ago

Ok, seams that you already have this_test_root/other_rstest_root.<i> with i from 0 to 42101912 and 42101913 crash (I can just guess that you exhausted your fs nodes)

But I don't think that're really valuable use cases for this crate. I cannot understand how you had done 42101912 runs in your tests but I can just guess something like you use a lot of temps directory in your tests... but just a guess

siretart commented 1 week ago

I can assure you that I did not do 42101912 runs, the test actually hung on the second attempt.

la10736 commented 1 week ago

Ok, so I can assume that the seconds test run cannot create the this_test_root/other_rstest_root.<nr> folders for some reasons.

la10736 commented 1 week ago

If I can spare some time I'll check it.

paulgevers commented 1 week ago

I happen to feel it might be related to https://lists.debian.org/debian-devel/2024/06/msg00041.html

la10736 commented 1 week ago

I don't think so.

In your case while the test should_resolve_root_in_env define RSTEST_TEMP_DIR_ROOT to this_test_root the should_resolve_rstest_temp_dir_root_name_in_env is started and incidentally use the same value for the root.

The first test when is completed delete the folder at https://github.com/la10736/temp_testdir/blob/master/src/lib.rs#L189 while the second one try to create this_test_root/other_rstest_root folder test in the wile loop https://github.com/la10736/temp_testdir/blob/master/src/lib.rs#L49: all attempts here will fails because the this_test_root was removed by the previous test.

Long story short: is not supported that you can change the environment variable while tests run.

I can fix them just by add serial tests annotation (use a lock under the hood) or run them on a single thread :

while true; do cargo test --all-features -- --test-threads=1; sleep 1; done