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

panic in Specie::generate_offspring() #19

Open
Boscop opened this issue Dec 24, 2017 · 7 comments · May be fixed by #45
Open

panic in Specie::generate_offspring() #19

Boscop opened this issue Dec 24, 2017 · 7 comments · May be fixed by #45

Comments

@Boscop
Copy link

Boscop commented Dec 24, 2017

After running it on my problem for like an hour (with no improvement), I got this panic:

thread 'main' panicked at 'Range::new called with `low >= high`', C:\Users\me\.c
argo\registry\src\github.com-1ecc6299db9ec823\rand-0.3.18\src\distributions\rang
e.rs:60:8
stack backtrace:
   0: std::sys_common::backtrace::_print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:92
   1: std::panicking::default_hook::{{closure}}
             at C:\projects\rust\src\libstd\panicking.rs:380
   2: std::panicking::default_hook
             at C:\projects\rust\src\libstd\panicking.rs:397
   3: std::panicking::rust_panic_with_hook
             at C:\projects\rust\src\libstd\panicking.rs:577
   4: <rand::ThreadRng as rand::Rng>::next_u64
   5: rustneat::specie::Specie::generate_offspring
   6: rustneat::population::Population::evolve
   7: ZIG_NORM_X
   8: ZIG_NORM_X
   9: panic_unwind::__rust_maybe_catch_panic
             at C:\projects\rust\src\libpanic_unwind\lib.rs:99
  10: std::rt::lang_start
             at C:\projects\rust\src\libstd\rt.rs:52
  11: __scrt_common_main_seh
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253
  12: BaseThreadInitThunk
@TLmaK0
Copy link
Owner

TLmaK0 commented Dec 25, 2017

Thanks, @Boscop, I will check this.

@shingtaklam1324
Copy link

@TLmaK0 I think I figured out the reason for the crash

let range = Range::new(0, self.organisms.len());

This calls

https://github.com/rust-lang-nursery/rand/blob/8ce74354f5fc771ac177b4a052f0b74660281cbf/src/distributions/range.rs#L59-L62

It requires that the lower bound to be less than (and not equal to) the upper bound. This means that if self.organisms.len() is 0, then the function will panic.

@TLmaK0
Copy link
Owner

TLmaK0 commented Feb 21, 2018

thanks @shingtaklam1324, could you investigate when the organisms is 0 in species? Test go through here without errors (normally).

@UrmelAusDemEis
Copy link

Hey Everyone,
I can confirm that this problem still exists. Have you guys made any process regarding this?

@TLmaK0
Copy link
Owner

TLmaK0 commented Jan 22, 2019

Hi @UrmelAusDemEis, I think it's fixed in feature/function_aproximation, but I have done a lot of changes there and I'm not sure that all is working right now

@UrmelAusDemEis
Copy link

Hi @TLmaK0, I just tried the other branch and the bug seems to be still in there

@TLmaK0
Copy link
Owner

TLmaK0 commented Jan 31, 2019

Thanks @UrmelAusDemEis, I will take a look!

teythoon pushed a commit to teythoon/rustneat that referenced this issue May 9, 2020
@teythoon teythoon linked a pull request May 9, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants