Comments (4)
Thanks for mentioning it. I think when I initially wrote it I also didn't like it too much because of how the code looks like. But I don't think anything is undefined here, since the length is not part of the uninitialized memory but kept by the compiler separately and then inserted into the DST.
I actually hope to replace all of those things with const generics once stable, which also should improve the code for these ringbuffers.
from futures-intrusive.
since the length is not part of the uninitialized memory but kept by the compiler separately and then inserted into the DST.
Again, the data access isn't what's relevant - the fact that the reference was created in the first place is.
cc @RalfJung am I misinterpreting here?
from futures-intrusive.
Changed in 3b15bf1
A where A: RealArray<MaybeUninit>
this wasn't great, since it would have required users to pass MaybeUninit
as a parameter to channel types - at least that's how I understood it. So I went for the associated constant version.
I still can't see how the reference would have been harmful since it is not really accessed and everything was already in an unsafe
block. However I see why the rule is in general unsafe guidelines since the actual behavior is hard to describe.
from futures-intrusive.
FWIW, @sfackler is right. Quoting from the reference: UB occurs when...
Producing an invalid value, even in private fields and locals.
"Producing" a value happens any time a value is assigned to or read from a place, passed to a function/primitive operation or returned from a function/primitive operation.
The following values are invalid (at their respective type):
[...] A reference orBox<T>
that is dangling, unaligned, or points to an invalid value.
The reason why even "unused" values need to be valid is that there are some very important compiler optimizations, such as hoisting operations out of loops, that can make unused variables used. (I have a blog post planned for that, but at my current schedule that's not going to happen this year...)
from futures-intrusive.
Related Issues (20)
- Channels with growing capacity HOT 2
- GenericWaitForEventFuture doesn't handle task migration. HOT 3
- GenericSemaphoreAcquireFuture isn't Sync HOT 7
- `Semaphore` cost O(waiters) time to wake up on, and quadratic in total HOT 2
- Channel::close should return previous state
- Unwind safety HOT 4
- shared::OneshotReceiver and cancellation HOT 2
- GenericOneshotBroadcastReceiver incorrectly requires MutexType to be Clone HOT 4
- LocalChannel backed by non-ArrayBuf RingBuf HOT 2
- NoopLock is unsound HOT 7
- Update `parking_lot` and `lock_api` HOT 1
- Pulling out intrusive data structures into another crate HOT 2
- GenericMutexGuard should be marked !Sync HOT 3
- Cut New Release With Updated Dependencies HOT 1
- Does this crate alias mutable references? HOT 1
- Maintenance Status HOT 1
- Possible breaking change in 0.4.1 release HOT 2
- Test failures in Fedora packaging HOT 2
- Use alloc instead of std HOT 2
- Support a shared Semaphor HOT 5
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 futures-intrusive.