-
Notifications
You must be signed in to change notification settings - Fork 277
Open
Description
While reviewing real-time issues in the source code of a custom Source, which uses UniformSourceIterator, RT-sanitizer noticed the following call to free, which is not real-time safe:
==3137==ERROR: RealtimeSanitizer: unsafe-library-call
Intercepted call to real-time unsafe function `free` in real-time context!
#0 0x558ee21b2218 in free /home/runner/work/rtsan-libs/rtsan-libs/llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:781:36
#1 0x558ee3f3f462 in _$LT$alloc..raw_vec..RawVec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hb7b789cbf687a464 /home/lino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/raw_vec/mod.rs:406:18
#2 0x558ee3f0a31a in core::ptr::drop_in_place$LT$alloc..raw_vec..RawVec$LT$f32$GT$$GT$::hbbace72dc3778dc1 /home/lino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:524:1
#3 0x558ee3f09f43 in core::ptr::drop_in_place$LT$alloc..vec..Vec$LT$f32$GT$$GT$::ha086ab91020cee54 /home/lino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:524:1
#4 0x558ee2192d9a in rodio::conversions::sample_rate::SampleRateConverter$LT$I$GT$::into_inner::h1bd55bdb7682e840 /home/lino/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rodio-0.21.1/src/conversions/sample_rate.rs:96:5
#5 0x558ee204f660 in _$LT$rodio..source..uniform..UniformSourceIterator$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::ha02484dbde2a47d6 /home/lino/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rodio-0.21.1/src/source/uniform.rs:82:21
#6 0x558ee2081e56 in _$LT$rodio_scheduler..Scheduler$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::haca8445718b4f9eb /home/lino/prj/coop-editor/rodio_scheduler/src/lib.rs:404:28
(The callstack then continues a bit further, omitted for clarity...)
SUMMARY: RealtimeSanitizer: unsafe-library-call /home/lino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/raw_vec/mod.rs:406:18 in _$LT$alloc..raw_vec..RawVec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hb7b789cbf687a464
I believe this is caused by the inner source of the UniformSourceIterator being dropped/taken and then bootstrapped again inside the body of UniformSourceIterator::next:
Lines 82 to 85 in 47dab16
| let input = self.inner.take().unwrap().into_inner().into_inner().iter; | |
| let mut input = | |
| UniformSourceIterator::bootstrap(input, self.target_channels, self.target_sample_rate); |
However, this behaviour dates back to at least 2015 from the history I've seen.
Is there a reason behind this design? Ideally I'd like to send a PR fixing it, but I would need some pointers first.
Metadata
Metadata
Assignees
Labels
No labels