-
Notifications
You must be signed in to change notification settings - Fork 59
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
What about: Virtual memory effects #28
Comments
Is it undefined behavior to have two pointers with different values referring to the same object? TL;DR:
and
With pretty much the recommendation that anything doing anything like this should use volatile load and stores. |
Oh but you can (but for unrelated reasons.^^) |
More on topic, AFAIK LLVM does not use aliasing information to inform ptr equality tests, and vice versa. So with a refined view of aliasing, I see no reason why LLVM's memory model would not work with overlapping virtual memory. |
Could you point me to which part of the blog post allows you to construct two pointers of different addresses that refer to the same object in C or C++ ? The only relevant example that I find there is the one of the out-of-bound pointers, but that's the opposite case, where one has two pointers, pointing to the same address, but that refer to two different objects - technically, one refers to an object, the other does not and is therefore illegal to dereference. |
You said "different values". The value of a pointer includes its provenance information. But I am just being picky here, that's off-topic -- sorry. |
This should definitely be a topic of discussion, especially because of the possibility that a filesystem process ends up |
@RalfJung No offense taken, that's an important difference! With EDIT: What I mean here with "on purpose" and "incidental" is that in the |
It seems unlikely to me that we'll want to adjust the AM memory model specifically to support this. I think that basically gives us very little wiggle room here. Option one for users is to use virtual memory shenanigans in a way that makes sense to the AM. This probably means not double-mapping pages. Option 2 is to use volatile operations, which are the standard tool for "I have some concept of memory that the AM doesn't understand." Is there anything I'm missing here? |
A one-mapping-per-process limit would be bad for composability. It would mean that libraries essentially could not make non-volatile accesses to writable mappings at all – even if they avoided data races using some external synchronization mechanism or using atomics – since they wouldn't know if some other library in the same process was using the same file. (That said, for the case of atomics, aren't you technically supposed to use volatile atomics for cross-process synchronization anyway? But the standard library has no support for those.) Is there any actual problem here other than |
During the pointer docs update, a discussion spawned off about effects of virtual memory: What do we still guarantee when different virtual addresses map to the same physical address? Some of libstd, e.g.
copy_nonoverlapping
, will start misbehaving in that situation. FWIW, C seems to just not care:memmove
has the same problem.The text was updated successfully, but these errors were encountered: