You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is caused by stack overflow. We have 16K stacks, but there are functions generated with ~20K frames!
The stack trace for that panic is:
(gdb) bt
#0 schedule_debug (prev=0xc0000000073c0080, preempt=true) at kernel/sched/core.c:4822
#1 0xc000000000609da8 in __schedule (preempt=<error reading variable: value has been optimised out>) at kernel/sched/core.c:4967
#2 0xc00000000060a6c4 in preempt_schedule_common () at kernel/sched/core.c:5233
#3 __cond_resched () at kernel/sched/core.c:6982
#4 0xc00000000029b9dc in might_alloc (gfp_mask=0) at /home/michael/src/rust/linux/./include/linux/sched/mm.h:197
#5 slab_pre_alloc_hook (s=0xc000000007011c80, objcgp=<optimised out>, size=<optimised out>, flags=0) at /home/michael/src/rust/linux/mm/slab.h:497
#6 slab_alloc_node (s=0xc000000007011c80, gfpflags=117513344, node=-1, addr=13835058055286880704, orig_size=<optimised out>) at mm/slub.c:2826
#7 slab_alloc (s=0xc000000007011c80, gfpflags=117513344, addr=13835058055286880704, orig_size=<optimised out>) at mm/slub.c:2915
#8 __kmalloc_track_caller (size=152, gfpflags=3264, caller=13835058055286880704) at mm/slub.c:4561
#9 0xc00000000024a050 in __do_krealloc (p=0x0, new_size=152, flags=11398400) at mm/slab_common.c:1153
#10 krealloc (p=0x0, new_size=152, flags=3264) at mm/slab_common.c:1186
#11 0xc00000000047f9c0 in kernel::allocator::__rust_alloc (size=152, _align=8) at /home/michael/src/rust/linux/rust/kernel/allocator.rs:35
#12 0xc0000000005bc2c8 in alloc::alloc::alloc (layout=...) at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:86
#13 0xc0000000005b6f04 in <alloc::alloc::Global>::alloc_impl (self=0xc0000000074024c0, layout=..., zeroed=false)
at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:166
#14 0xc0000000005bdf38 in <alloc::alloc::Global as core::alloc::Allocator>::allocate (self=0xc0000000074024c0, layout=...)
at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:226
#15 0xc0000000005bb1c8 in <alloc::boxed::Box<kernel::sync::mutex::Mutex<i32>>>::try_new_uninit_in (alloc=...)
at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:425
#16 0xc0000000005bb09c in <alloc::boxed::Box<kernel::sync::mutex::Mutex<i32>>>::try_new_in (x=..., alloc=...)
at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:360
#17 0xc0000000005b71c0 in <alloc::boxed::Box<kernel::sync::mutex::Mutex<i32>>>::try_new (x=...)
at /home/michael/.rustup/toolchains/nightly-2021-02-20-powerpc64le-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:261
#18 0xc0000000005c08b8 in <rust_example::RustExample as kernel::KernelModule>::init () at /home/michael/src/rust/linux/drivers/char/rust_example.rs:192
#19 0xc0000000005c196c in rust_example::__init () at /home/michael/src/rust/linux/drivers/char/rust_example.rs:21
#20 0xc0000000005c18d8 in rust_example::__rust_example_init () at /home/michael/src/rust/linux/drivers/char/rust_example.rs:21
#21 0xc00000000001112c in do_one_initcall (fn=0xc0000000005c18c0 <rust_example::__rust_example_init>) at init/main.c:1226
#22 0xc0000000009c5be8 in do_initcall_level (level=<optimised out>, command_line=<optimised out>) at init/main.c:1299
#23 0xc0000000009c5ab4 in do_initcalls () at init/main.c:1315
#24 0xc0000000009c5a20 in do_basic_setup () at init/main.c:1335
#25 0xc0000000009c5904 in kernel_init_freeable () at init/main.c:1537
#26 0xc000000000011f7c in kernel_init (unused=<optimised out>) at init/main.c:1424
#27 0xc00000000000cb78 in ret_from_kernel_thread () at arch/powerpc/kernel/entry_64.S:416
Looking up the stack I see this function:
(gdb) up
#18 0xc0000000005c08b8 in _RNvXs3_CsbDqzXfLQacH_12rust_exampleNtB5_11RustExampleNtCsbDqzXfLQacH_6kernel12KernelModule4init () at /home/michael/src/rust/linux/drivers/char/rust_example.rs:192
<rust_example::RustExample as kernel::KernelModule>::init
192 let data = Pin::from(Box::try_new(unsafe { Mutex::new(0) })?);
It would be nice to do it, yeah. We should also add a comment in CONFIG_RUST_OPT_LEVEL_0 and 1 explaining that the stack size might need a substantial increase in some cases.
Also please update Doc/rust/arch-support.rst to remove the restriction! :-)
Activity
mpe commentedon Apr 10, 2021
This is caused by stack overflow. We have 16K stacks, but there are functions generated with ~20K frames!
The stack trace for that panic is:
Looking up the stack I see this function:
The disassembly is:
That
stduis creating a20528byte stack frame.Building with
-Z emit-stack-sizesI see ~30 Rust functions that have large (> 2KB) frames.mpe commentedon Apr 10, 2021
I can fix the CI failure at opt level 0 by increasing the stack size, do we want to do that for now?
See mpe/linux@27a1886
ojeda commentedon Apr 10, 2021
It would be nice to do it, yeah. We should also add a comment in
CONFIG_RUST_OPT_LEVEL_0and1explaining that the stack size might need a substantial increase in some cases.Also please update
Doc/rust/arch-support.rstto remove the restriction! :-)mpe commentedon Apr 13, 2021
For the record here are the functions I see with frames > 2KB:
netfilter: nft_set_pipapo: release elements in clone from abort path
drm/drm_exec: Work around a WW mutex lockdep oddity
drm/tests: helpers: Avoid a driver uaf