Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow #1076

Open
stphnt opened this issue Jan 18, 2025 · 2 comments
Open

Stack overflow #1076

stphnt opened this issue Jan 18, 2025 · 2 comments
Labels
C-bug Category: doesn't meet expectations

Comments

@stphnt
Copy link

stphnt commented Jan 18, 2025

Steps to reproduce the bug with the above code

Run cargo semver-checks on main of https://github.com/stphnt/zproto.

Actual Behaviour

It overflows the stack and is aborted. The output looks like this:

    Building zproto v0.4.1 (current)
       Built [   1.093s] (current)
     Parsing zproto v0.4.1 (current)
      Parsed [   0.058s] (current)
     Parsing zproto v0.4.0 (baseline, cached)
      Parsed [   0.054s] (baseline)
    Checking zproto v0.4.0 -> v0.4.1 (minor change)

thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow

[2]    21582 IOT instruction (core dumped)  cargo semver-checks

Expected Behaviour

It shouldn't overflow the stack :)

Generated System Information

Software version

cargo-semver-checks 0.38.0

Operating system

Linux 6.11.11-1-MANJARO

Command-line

/home/stephen/.cargo/bin/cargo-semver-checks semver-checks --bugreport 

cargo version

> cargo -V 
cargo 1.84.0 (66221abde 2024-11-19)

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Build Configuration

None

Additional Context

Here is a snippet of the backtrace from the coredump. It makes approximately ~10000 alternating calls to

trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x0000747d2be47463 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x0000747d2bdee120 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x0000747d2bdd54c3 in __GI_abort () at abort.c:79
#4  0x000060ddd2b8ae8a in std::sys::pal::unix::abort_internal ()
#5  0x000060ddd2b893d2 in std::sys::pal::unix::stack_overflow::imp::signal_handler ()
#6  <signal handler called>
#7  0x000060ddd25f2aa2 in core::hash::BuildHasher::hash_one ()
#8  0x000060ddd25e2be5 in trustfall_rustdoc_adapter::visibility_tracker::VisibilityTracker::collect_publicly_importable_names_inner ()
#9  0x000060ddd25e3066 in trustfall_rustdoc_adapter::visibility_tracker::VisibilityTracker::collect_publicly_importable_names_inner ()
#10 0x000060ddd25e3066 in trustfall_rustdoc_adapter::visibility_tracker::VisibilityTracker::collect_publicly_importable_names_inner ()
#11 0x000060ddd25e2acc in trustfall_rustdoc_adapter::visibility_tracker::VisibilityTracker::collect_publicly_importable_names ()
#12 0x000060ddd25de9d3 in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#13 0x000060ddd25df38a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#14 0x000060ddd25deedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#15 0x000060ddd25df38a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#16 0x000060ddd25deedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#17 0x000060ddd25df38a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#18 0x000060ddd25deedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#19 0x000060ddd25df38a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#20 0x000060ddd25deedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#21 0x000060ddd25df38a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
<snipped ...>
#10250 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10251 0x000059126606038a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#10252 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10253 0x000059126606038a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#10254 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10255 0x000059126606038a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#10256 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10257 0x000059126606038a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#10258 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10259 0x000059126606038a in trustfall_rustdoc_adapter::sealed_trait::has_no_externally_satisfiable_blanket_impls ()
#10260 0x000059126605fedb in trustfall_rustdoc_adapter::sealed_trait::is_trait_sealed ()
#10261 0x000059126550ca67 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10262 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10263 0x000059126549a1b0 in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10264 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10265 0x00005912655aa05f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10266 0x00005912654bc1ef in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10267 0x00005912655bb5f4 in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next ()
#10268 0x000059126550ba0f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10269 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10270 0x0000591265491afa in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10271 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10272 0x00005912655aa05f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10273 0x00005912654ba74f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10274 0x00005912655bb5f4 in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next ()
#10275 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10276 0x00005912655aa05f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10277 0x00005912655b2b96 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10278 0x00005912655090cf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10279 0x00005912655a9593 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10280 0x0000591265802085 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10281 0x00005912657ff404 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10282 0x00005912655bb5f4 in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next ()
#10283 0x00005912657bee0f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10284 0x00005912655bfc5b in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10285 0x0000591265510a9f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10286 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10287 0x0000591265491afa in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10288 0x000059126550912f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10289 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10290 0x0000591265491de4 in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10291 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10292 0x00005912655aa05f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10293 0x00005912654bc1ef in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10294 0x00005912655bb5f4 in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next ()
#10295 0x00005912655090cf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10296 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10297 0x00005912655b2b96 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10298 0x00005912655090cf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10299 0x00005912655a9593 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10300 0x0000591265475218 in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10301 0x000059126550ba0f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10302 0x00005912655b8872 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10303 0x0000591265491afa in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10304 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10305 0x00005912655aa05f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10306 0x00005912654ba93f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10307 0x00005912655bb5f4 in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next ()
#10308 0x00005912655aaadf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10309 0x00005912655b8544 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10310 0x0000591265505b0f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10311 0x00005912655b36d2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10312 0x00005912655b8544 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10313 0x00005912655090cf in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10314 0x00005912655b36d2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10315 0x00005912655b8544 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10316 0x00005912655065c2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10317 0x00005912655b36d2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10318 0x00005912655b8544 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10319 0x000059126550e5af in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10320 0x00005912655b36d2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10321 0x00005912655b8544 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10322 0x0000591265510a9f in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10323 0x00005912655b36d2 in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10324 0x00005912655b65ba in <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next ()
#10325 0x00005912656d165b in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter ()
#10326 0x00005912656e6766 in core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once ()
#10327 0x00005912656ceb48 in <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend ()
#10328 0x00005912655f1e6c in rayon::iter::plumbing::bridge_producer_consumer::helper ()
#10329 0x00005912658099d7 in rayon_core::join::join_context::{{closure}} ()
#10330 0x00005912655f1fe3 in rayon::iter::plumbing::bridge_producer_consumer::helper ()
#10331 0x0000591265809bd1 in rayon_core::join::join_context::{{closure}} ()
#10332 0x00005912655f1fe3 in rayon::iter::plumbing::bridge_producer_consumer::helper ()
#10333 0x0000591265809bd1 in rayon_core::join::join_context::{{closure}} ()
#10334 0x00005912655f1fe3 in rayon::iter::plumbing::bridge_producer_consumer::helper ()
#10335 0x00005912658099d7 in rayon_core::join::join_context::{{closure}} ()
#10336 0x00005912655f1fe3 in rayon::iter::plumbing::bridge_producer_consumer::helper ()
#10337 0x000059126583dbea in <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute ()
#10338 0x000059126539d3b2 in rayon_core::registry::WorkerThread::wait_until_cold ()
#10339 0x00005912664bb05b in rayon_core::registry::ThreadBuilder::run ()
#10340 0x00005912664bcb7a in std::sys::backtrace::__rust_begin_short_backtrace ()
#10341 0x00005912664bfa8a in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#10342 0x000059126660aabb in std::sys::pal::unix::thread::Thread::new::thread_start ()
#10343 0x0000798d8a8ed39d in start_thread (arg=<optimized out>) at pthread_create.c:447
#10344 0x0000798d8a97249c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Here is a CI job that also fails in the same way: https://github.com/stphnt/zproto/actions/runs/12826235825/job/35765760201?pr=189.

@stphnt stphnt added the C-bug Category: doesn't meet expectations label Jan 18, 2025
@obi1kenobi
Copy link
Owner

Reproduced, thank you. Minimal repro:

mod recursive {
    pub trait RecursiveSealed {}

    impl<T: super::SealedPlusRecursiveBlanket> RecursiveSealed for &T {}
}

pub trait SealedPlusRecursiveBlanket: recursive::RecursiveSealed {}

impl<T: SealedPlusRecursiveBlanket> SealedPlusRecursiveBlanket for &T {}

When originally writing the sealed trait analysis code, I tried hard to come up with cases of cyclic bounds. Rustc kept rejecting all my attempts, so after a while, I gave up and decided it's probably impossible.

This is an example of such a cyclic bound. Sorry about the bug, and nice catch :)

@stphnt
Copy link
Author

stphnt commented Jan 19, 2025

Glad it wasn't too hard to reproduce. Thanks for your work on this project! Looking forward to using semver-checks more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: doesn't meet expectations
Projects
None yet
Development

No branches or pull requests

2 participants