-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix EntityMeta.spawned_or_despawned unsoundness #19350
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
Fix EntityMeta.spawned_or_despawned unsoundness #19350
Conversation
0385ed6
to
2d7d80f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a sensible solution, with two things to clear up.
I also wonder if the internal method names and SpawnedOrDespawned
should be renamed to reflect that flushing also updating these values, not only spawn/despawn. "spawn_or_despawn_or_flush
" is quite long though, maybe updated_at
/updated_by
is fine in EntityMeta
. After all without MaybeUninit
these two fields dont need to be in a separate type anymore.
I think this PR and your nickname belongs to the feature's release note by the way. 😉
by: MaybeLocation, | ||
at: Tick, | ||
) { | ||
pub(crate) unsafe fn mark_spawn_despawn(&mut self, index: u32, by: MaybeLocation, at: Tick) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the idea behind separating this and set
? This here still gets called next to set
, adding another indexing into the same EntityMeta
. You already added S-Needs-Benchmarking so I am interested if this has bad effects or just gets optimized away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be a perf difference between those given that they should get inlined, but I'll check anyways. I think it's a bit cleaner, but I don't have a strong opinion – if you prefer, I'll happily revert that part :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it makes no difference it is fine either way for me. Originally these calls were more apart so I doubt it was inlining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, during spawning via Commands, it's only mark_spawn_despawn
without a combined archetype location update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it, could you link to that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was unclear: #19351
Agree about the name, but
Yes. I've still kept the type because of
noted |
2d7d80f
to
c5f1bb4
Compare
If you don't mind, in the release note in the |
c5f1bb4
to
576ee0b
Compare
@SpecificProtagonist can you take a look at the CI logs? |
Co-authored-by: urben1680 <[email protected]>
6067dba
to
98633e4
Compare
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
Objective
#19047 added an
MaybeUninit
field toEntityMeta
, but did not guarantee that it will be initialized before access:Miri Error
Solution
MaybeUninit
inEntityMeta.spawned_or_despawned
Testing
Test via the snippet above (also added equivalent test).