Skip to content

Possible panic issue in set_for_current #345

@kitcatier

Description

@kitcatier

Hello, I found a soundness issue in this crate.

pub fn set_for_current(core_id: CoreId) {
tracing::trace!("Executor: placement: set affinity on core {}", core_id.id);
set_for_current_helper(core_id);
}

Here's a quick example of this issue:

extern crate bastion_executor;
use bastion_executor::placement::CoreId;

fn main() {
    let a:CoreId = CoreId { id: 771157545605903283 };
    let _ = bastion_executor::placement::set_for_current(a);
}

This outputs:

thread 'main' panicked at 'attempt to shift left with overflow', C:\Users\.cargo\registry\src\github.com-1ecc6299db9ec823\bastion-executor-0.4.2\src\placement.rs:216:31
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/73c9eaf21454b718e7c549984d9eb6e1f75e995c/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/73c9eaf21454b718e7c549984d9eb6e1f75e995c/library\core\src\panicking.rs:65
   2: core::panicking::panic
             at /rustc/73c9eaf21454b718e7c549984d9eb6e1f75e995c/library\core\src\panicking.rs:115
   3: bastion_executor::placement::windows::set_for_current
             at C:\Users\.cargo\registry\src\github.com-1ecc6299db9ec823\bastion-executor-0.4.2\src\placement.rs:216
   4: bastion_executor::placement::set_for_current_helper
             at C:\Users\.cargo\registry\src\github.com-1ecc6299db9ec823\bastion-executor-0.4.2\src\placement.rs:180
   5: bastion_executor::placement::set_for_current
             at C:\Users\.cargo\registry\src\github.com-1ecc6299db9ec823\bastion-executor-0.4.2\src\placement.rs:22
   6: hello::main
             at .\src\main.rs:14
   7: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/73c9eaf21454b718e7c549984d9eb6e1f75e995c\library\core\src\ops\function.rs:510
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions