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: add with overflow in exclusive function system #7140

Closed
zheilbron opened this issue Jan 9, 2023 · 3 comments
Closed

Panic: add with overflow in exclusive function system #7140

zheilbron opened this issue Jan 9, 2023 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy
Milestone

Comments

@zheilbron
Copy link

Bevy version

0.9.1

What you did

I left the system running overnight.

What went wrong

thread 'main' panicked at 'attempt to add with overflow', /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.9.1/src/system/exclusive_function_system.rs:106:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
   2: core::panicking::panic
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:115:5
   3: <bevy_ecs::system::exclusive_function_system::ExclusiveFunctionSystem<Param,Marker,F> as bevy_ecs::system::system::System>::run
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.9.1/src/system/exclusive_function_system.rs:106:9
   4: <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.9.1/src/schedule/stage.rs:782:29
   5: bevy_ecs::schedule::Schedule::run_once
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.9.1/src/schedule/mod.rs:370:13
   6: bevy_app::app::App::update
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.1/src/app.rs:152:9
   7: <bevy_app::schedule_runner::ScheduleRunnerPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::{{closure}}
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.1/src/schedule_runner.rs:94:25
   8: <bevy_app::schedule_runner::ScheduleRunnerPlugin as bevy_app::plugin::Plugin>::build::{{closure}}
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.1/src/schedule_runner.rs:119:47
   9: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:2001:9
  10: bevy_app::app::App::run
             at /Users/zheilbron/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.1/src/app.rs:168:9
  11: spiritbound_server::main
             at ./server/src/main.rs:21:5
  12: core::ops::function::FnOnce::call_once
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/ops/function.rs:251:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@zheilbron zheilbron added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 9, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Jan 9, 2023
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jan 9, 2023

The line responsible: it's a change tick issue, as I suspected. @maniwani should we just be doing a wrapping addition here, or is there a more complex strategy required?

@maniwani
Copy link
Contributor

maniwani commented Jan 9, 2023

Should we just be doing a wrapping addition here, or is there a more complex strategy required?

Wow, apparently, we had this bug even before exclusive systems were changed. Yes, we should be using wrapping_add here to match the fetch_add used by non-exclusive systems (which wraps on overflow in both debug and release mode).

@alice-i-cecile alice-i-cecile added the D-Trivial Nice and easy! A great choice to get started with Bevy label Jan 9, 2023
@alice-i-cecile alice-i-cecile added this to the 0.10 milestone Jan 9, 2023
@Tirthnp
Copy link
Contributor

Tirthnp commented Jan 10, 2023

Hi, I just added a PR for this. Let me know if I am missing anything, as it's my first time contributing :)

@bors bors bot closed this as completed in a207178 Jan 10, 2023
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

Fixes bevyengine#7140


## Solution

As discussed in the issue, added wrapping_add

---
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

Fixes bevyengine#7140


## Solution

As discussed in the issue, added wrapping_add

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants