Comments (4)
Took a stab at it #26
Why does it need the static?
If my model of lifetimes is correct, then the port's would also need to be static in this case.
from rust-jack.
It's the whole "mem::forget
is stable" thing. If you call mem::forget
on a Client
, the client's registered callbacks will continue to be triggered for the duration of the process (unless you manually deregister them later on). Therefore, any resources used in the callback must be valid for the 'static
lifetime.
from rust-jack.
To give an example, here's a modified version of the playback_capture
example that demonstrates this unsoundness:
let x = 5;
let x_ref = &x;
let process_callback =
ProcessClosure::new(move |ps: &jack::ProcessScope| -> jack::JackControl {
// x_ref must still be valid here!
let closure_x = *x_ref;
out_a.data(ps).buffer().clone_from_slice(in_a.data(ps).buffer());
out_b.data(ps).buffer().clone_from_slice(in_b.data(ps).buffer());
jack::JackControl::Continue
});
// Activate the client, which starts the processing
let active_client = client.activate(process_callback).unwrap();
mem::forget(active_client);
// Client is forgotten but not deregistered, stack pops up and x is lost
// Callback then dereferences x_ref and gains access to stack garbage
from rust-jack.
Fixed in #26
from rust-jack.
Related Issues (20)
- better documentation for side effects of AsyncClient::drop HOT 2
- failure to link with pipewire-jack-audio-connection-kit-devel HOT 3
- Documentation missing HOT 5
- Loopback HOT 1
- Why is `Client`/`AsyncClient` not `Sync`? HOT 3
- ClosureProcessHandler API does not have a way to set a buffer_size callback HOT 3
- Client::connect_ports compiles if input and output ports are swapped
- dynamically load libjack at runtime instead of linking HOT 6
- Deactivating client causes a panic HOT 6
- Remove special treatment of jack_get_cycle_times HOT 1
- no Git tags for releases
- Support compile time linking. HOT 5
- Replace codegen in jack-sys/build.rs with macro
- Client::new() panics when JACK is not installed HOT 3
- Reporting latency
- aarch64 support? HOT 1
- local directories are leaked to binary
- Request capability to specify additional flags for AudioIn, AudioOut, MidiIn and MidiOut types
- Verbose/debug logging
- Who is maintaining this repo/crate? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-jack.