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

Concurrency Bug causes DoS #26

Open
TheAlgorythm opened this issue Jul 20, 2021 · 2 comments
Open

Concurrency Bug causes DoS #26

TheAlgorythm opened this issue Jul 20, 2021 · 2 comments

Comments

@TheAlgorythm
Copy link

I am using rust_gpiozero v0.2.1 with an Raspberry Pi 4B and found a situation where the library isn't responding to interrupts.
I'm not a 100% sure that it is a concurrency bug, but I was only able to replicate the problem in a concurrent situation.
The following minimal reproducible example responds only alternating between the pins and doesn't continue on every falling edge.

use std::thread;
use std::time::Duration;
use rust_gpiozero::input_devices::DigitalInputDevice;

fn event_loop(pin: u8) -> thread::JoinHandle<()> {
   thread::spawn(move || {
	let mut dev = DigitalInputDevice::new(pin);
	println!("init {} done", pin);
	let mut counter = 0_usize;
	loop {
		println!("await {} off {}", pin, counter);
		dev.wait_for_inactive(None);
		println!("awaited {} off {}", pin, counter);
		thread::sleep(Duration::from_millis(100));
		counter += 1;
	}
   })
}

fn main() {
    let first_el = event_loop(6);
    event_loop(16).join().unwrap();
    first_el.join().unwrap();
}
@TheAlgorythm
Copy link
Author

I investigated the problem and it is somewhere in rppal.
See golemparts/rppal#92

@TheAlgorythm
Copy link
Author

Please document that only one interrupt in parallel is possible.

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

No branches or pull requests

1 participant