Let's take a closer look. If you run gdb on this program:
Click to expand the rest of the output
Breakpoint 1, __GI___libc_malloc (bytes=bytes@entry=120) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=bytes@entry=120) at ./malloc/malloc.c:3294
#1 0x00007ffff7df4d85 in __GI___getdelim (lineptr=lineptr@entry=0x7fffffffe2e0, n=n@entry=0x7fffffffe2e8, delimiter=delimiter@entry=10, fp=fp@entry=0x5555555aa2a0) at ./libio/iogetdelim.c:65
#2 0x00007ffff7dcd7c1 in __getline (lineptr=lineptr@entry=0x7fffffffe2e0, n=n@entry=0x7fffffffe2e8, stream=stream@entry=0x5555555aa2a0) at ./stdio-common/getline.c:28
#3 0x00007ffff7e0c20f in __pthread_getattr_np (thread_id=140737351432064, attr=0x7fffffffe360) at ./nptl/pthread_getattr_np.c:122
#4 0x000055555558cc0e in std::sys::pal::unix::stack_overflow::imp::get_stack_start () at library/std/src/sys/pal/unix/stack_overflow.rs:372
#5 std::sys::pal::unix::stack_overflow::imp::stack_start_aligned () at library/std/src/sys/pal/unix/stack_overflow.rs:389
#6 std::sys::pal::unix::stack_overflow::imp::install_main_guard_linux () at library/std/src/sys/pal/unix/stack_overflow.rs:442
#7 std::sys::pal::unix::stack_overflow::imp::install_main_guard () at library/std/src/sys/pal/unix/stack_overflow.rs:413
#8 std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:155
#9 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#10 std::rt::init () at library/std/src/rt.rs:118
#11 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#12 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#13 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#14 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#15 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#16 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#17 0x0000555555567a5e in main ()
#18 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#19 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#20 0x0000555555567855 in _start ()
Breakpoint 1, __GI___libc_malloc (bytes=bytes@entry=1024) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=bytes@entry=1024) at ./malloc/malloc.c:3294
#1 0x00007ffff7df31b5 in __GI__IO_file_doallocate (fp=0x5555555aa2a0) at ./libio/filedoalloc.c:101
#2 0x00007ffff7e03524 in __GI__IO_doallocbuf (fp=fp@entry=0x5555555aa2a0) at ./libio/libioP.h:1030
#3 0x00007ffff7e00884 in _IO_new_file_underflow (fp=0x5555555aa2a0) at ./libio/fileops.c:486
#4 0x00007ffff7df4e10 in __GI___getdelim (lineptr=lineptr@entry=0x7fffffffe2e0, n=n@entry=0x7fffffffe2e8, delimiter=delimiter@entry=10, fp=fp@entry=0x5555555aa2a0) at ./libio/iogetdelim.c:77
#5 0x00007ffff7dcd7c1 in __getline (lineptr=lineptr@entry=0x7fffffffe2e0, n=n@entry=0x7fffffffe2e8, stream=stream@entry=0x5555555aa2a0) at ./stdio-common/getline.c:28
#6 0x00007ffff7e0c20f in __pthread_getattr_np (thread_id=140737351432064, attr=0x7fffffffe360) at ./nptl/pthread_getattr_np.c:122
#7 0x000055555558cc0e in std::sys::pal::unix::stack_overflow::imp::get_stack_start () at library/std/src/sys/pal/unix/stack_overflow.rs:372
#8 std::sys::pal::unix::stack_overflow::imp::stack_start_aligned () at library/std/src/sys/pal/unix/stack_overflow.rs:389
#9 std::sys::pal::unix::stack_overflow::imp::install_main_guard_linux () at library/std/src/sys/pal/unix/stack_overflow.rs:442
#10 std::sys::pal::unix::stack_overflow::imp::install_main_guard () at library/std/src/sys/pal/unix/stack_overflow.rs:413
#11 std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:155
#12 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#13 std::rt::init () at library/std/src/rt.rs:118
#14 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#15 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#16 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#17 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#18 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#19 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#20 0x0000555555567a5e in main ()
#21 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#22 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#23 0x0000555555567855 in _start ()
Breakpoint 1, __GI___libc_malloc (bytes=bytes@entry=32) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=bytes@entry=32) at ./malloc/malloc.c:3294
#1 0x00007ffff7e1c10c in __GI___libc_realloc (oldmem=oldmem@entry=0x0, bytes=bytes@entry=32) at ./malloc/malloc.c:3425
#2 0x00007ffff7e0bf7a in __pthread_getattr_np (thread_id=140737351432064, attr=0x7fffffffe360) at ./nptl/pthread_getattr_np.c:180
#3 0x000055555558cc0e in std::sys::pal::unix::stack_overflow::imp::get_stack_start () at library/std/src/sys/pal/unix/stack_overflow.rs:372
#4 std::sys::pal::unix::stack_overflow::imp::stack_start_aligned () at library/std/src/sys/pal/unix/stack_overflow.rs:389
#5 std::sys::pal::unix::stack_overflow::imp::install_main_guard_linux () at library/std/src/sys/pal/unix/stack_overflow.rs:442
#6 std::sys::pal::unix::stack_overflow::imp::install_main_guard () at library/std/src/sys/pal/unix/stack_overflow.rs:413
#7 std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:155
#8 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#9 std::rt::init () at library/std/src/rt.rs:118
#10 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#11 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#12 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#13 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#14 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#15 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#16 0x0000555555567a5e in main ()
#17 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#18 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#19 0x0000555555567855 in _start ()
Breakpoint 1, __GI___libc_malloc (bytes=bytes@entry=32) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=bytes@entry=32) at ./malloc/malloc.c:3294
#1 0x00007ffff7e1c10c in __GI___libc_realloc (oldmem=<optimized out>, bytes=bytes@entry=32) at ./malloc/malloc.c:3425
#2 0x00007ffff7e081d9 in __GI___pthread_attr_setaffinity_np (attr=attr@entry=0x7fffffffe360, cpusetsize=cpusetsize@entry=32, cpuset=cpuset@entry=0x5555555aaa10)
at ./nptl/pthread_attr_setaffinity.c:51
#3 0x00007ffff7e0c008 in __pthread_getattr_np (thread_id=<optimized out>, attr=0x7fffffffe360) at ./nptl/pthread_getattr_np.c:194
#4 0x000055555558cc0e in std::sys::pal::unix::stack_overflow::imp::get_stack_start () at library/std/src/sys/pal/unix/stack_overflow.rs:372
#5 std::sys::pal::unix::stack_overflow::imp::stack_start_aligned () at library/std/src/sys/pal/unix/stack_overflow.rs:389
#6 std::sys::pal::unix::stack_overflow::imp::install_main_guard_linux () at library/std/src/sys/pal/unix/stack_overflow.rs:442
#7 std::sys::pal::unix::stack_overflow::imp::install_main_guard () at library/std/src/sys/pal/unix/stack_overflow.rs:413
#8 std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:155
#9 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#10 std::rt::init () at library/std/src/rt.rs:118
#11 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#12 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#13 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#14 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#15 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#16 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#17 0x0000555555567a5e in main ()
#18 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#19 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#20 0x0000555555567855 in _start ()
Breakpoint 1, __GI___libc_malloc (bytes=4) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=4) at ./malloc/malloc.c:3294
#1 0x000055555558f1e8 in alloc::alloc::alloc () at library/alloc/src/alloc.rs:95
#2 alloc::alloc::Global::alloc_impl_runtime () at library/alloc/src/alloc.rs:190
#3 alloc::alloc::Global::alloc_impl () at library/alloc/src/alloc.rs:312
#4 alloc::alloc::{impl#1}::allocate () at library/alloc/src/alloc.rs:429
#5 alloc::boxed::{impl#3}::try_clone_from_ref_in<str, alloc::alloc::Global> () at library/alloc/src/boxed.rs:872
#6 alloc::boxed::{impl#3}::clone_from_ref_in<str, alloc::alloc::Global> () at library/alloc/src/boxed.rs:831
#7 alloc::boxed::{impl#2}::clone_from_ref<str> () at library/alloc/src/boxed.rs:784
#8 alloc::boxed::convert::{impl#5}::from () at library/alloc/src/boxed/convert.rs:138
#9 core::ops::function::FnOnce::call_once<fn(&str) -> alloc::boxed::Box<str, alloc::alloc::Global>, (&str)> () at library/core/src/ops/function.rs:250
#10 core::option::Option::map<&str, alloc::boxed::Box<str, alloc::alloc::Global>, fn(&str) -> alloc::boxed::Box<str, alloc::alloc::Global>> () at library/core/src/option.rs:1165
#11 std::sys::pal::unix::stack_overflow::thread_info::set_current_info::{closure#0} () at library/std/src/sys/pal/unix/stack_overflow/thread_info.rs:114
#12 std::thread::current::with_current_name::{closure#0}<std::sys::pal::unix::stack_overflow::thread_info::set_current_info::{closure_env#0}, core::option::Option<alloc::boxed::Box<str, alloc::alloc::Global>>> () at library/std/src/thread/current.rs:234
#13 std::thread::current::try_with_current<std::thread::current::with_current_name::{closure_env#0}<std::sys::pal::unix::stack_overflow::thread_info::set_current_info::{closure_env#0}, core::option::Option<alloc::boxed::Box<str, alloc::alloc::Global>>>, core::option::Option<alloc::boxed::Box<str, alloc::alloc::Global>>> () at library/std/src/thread/current.rs:204
#14 std::thread::current::with_current_name<std::sys::pal::unix::stack_overflow::thread_info::set_current_info::{closure_env#0}, core::option::Option<alloc::boxed::Box<str, alloc::alloc::Global>>>
() at library/std/src/thread/current.rs:216
#15 std::sys::pal::unix::stack_overflow::thread_info::set_current_info () at library/std/src/sys/pal/unix/stack_overflow/thread_info.rs:114
#16 0x000055555558cd3d in std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:179
#17 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#18 std::rt::init () at library/std/src/rt.rs:118
#19 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#20 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#21 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#22 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#23 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#24 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#25 0x0000555555567a5e in main ()
#26 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#27 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#28 0x0000555555567855 in _start ()
Breakpoint 1, __GI___libc_malloc (bytes=544) at ./malloc/malloc.c:3294
3294 in ./malloc/malloc.c
#0 __GI___libc_malloc (bytes=544) at ./malloc/malloc.c:3294
#1 0x000055555558f3ea in alloc::alloc::alloc () at library/alloc/src/alloc.rs:95
#2 alloc::alloc::Global::alloc_impl_runtime () at library/alloc/src/alloc.rs:190
#3 alloc::alloc::Global::alloc_impl () at library/alloc/src/alloc.rs:312
#4 alloc::alloc::{impl#1}::allocate () at library/alloc/src/alloc.rs:429
#5 alloc::boxed::{impl#1}::try_new_uninit_in<alloc::collections::btree::node::LeafNode<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo>, alloc::alloc::Global> ()
at library/alloc/src/boxed.rs:614
#6 alloc::boxed::{impl#1}::new_uninit_in<alloc::collections::btree::node::LeafNode<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo>, alloc::alloc::Global> ()
at library/alloc/src/boxed.rs:581
#7 alloc::collections::btree::node::LeafNode::new<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo, alloc::alloc::Global> () at library/alloc/src/collections/btree/node.rs:87
#8 alloc::collections::btree::node::NodeRef::new_leaf<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo, alloc::alloc::Global> ()
at library/alloc/src/collections/btree/node.rs:225
#9 alloc::collections::btree::map::entry::VacantEntry::insert_entry<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo, alloc::alloc::Global> ()
at library/alloc/src/collections/btree/map/entry.rs:403
#10 alloc::collections::btree::map::entry::VacantEntry::insert<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo, alloc::alloc::Global> ()
at library/alloc/src/collections/btree/map/entry.rs:377
#11 alloc::collections::btree::map::BTreeMap::insert<usize, std::sys::pal::unix::stack_overflow::thread_info::ThreadInfo, alloc::alloc::Global> () at library/alloc/src/collections/btree/map.rs:1053
#12 std::sys::pal::unix::stack_overflow::thread_info::set_current_info () at library/std/src/sys/pal/unix/stack_overflow/thread_info.rs:122
#13 0x000055555558cd3d in std::sys::pal::unix::stack_overflow::imp::init () at library/std/src/sys/pal/unix/stack_overflow.rs:179
#14 std::sys::pal::unix::init () at library/std/src/sys/pal/unix/mod.rs:41
#15 std::rt::init () at library/std/src/rt.rs:118
#16 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:173
#17 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:581
#18 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:544
#19 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#20 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#21 0x0000555555567957 in std::rt::lang_start<std::process::ExitCode> (main=0x555555567a20 <main::main>, argc=1, argv=0x7fffffffe5c8, sigpipe=0)
at /home/martin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205
#22 0x0000555555567a5e in main ()
#23 0x00007ffff7d981ca in __libc_start_call_main (main=main@entry=0x555555567a40 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe5c8) at ../sysdeps/nptl/libc_start_call_main.h:58
#24 0x00007ffff7d9828b in __libc_start_main_impl (main=0x555555567a40 <main>, argc=1, argv=0x7fffffffe5c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe5b8) at ../csu/libc-start.c:360
#25 0x0000555555567855 in _start ()
(The backtraces are more pleasant to look at in your own terminal where they are formated with colors.)