-
Notifications
You must be signed in to change notification settings - Fork 44
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
Change how mutability in msg_send!
is done
#150
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
madsmtm
added
bug
Something isn't working
help wanted
Extra attention is needed
A-objc2
Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates
labels
May 24, 2022
madsmtm
changed the title
Change
Change how mutability in May 24, 2022
msg_send!
such that callers can properly communicate mutabilitymsg_send!
is done
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
from
May 26, 2022 12:59
f1edce7
to
763efa1
Compare
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
from
June 6, 2022 15:16
763efa1
to
d026568
Compare
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
from
June 6, 2022 15:34
d026568
to
854b252
Compare
I'll go with idea 3, to make |
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
4 times, most recently
from
June 6, 2022 15:59
67d85b6
to
802f8c2
Compare
This fixes a long-standing soundness issue with how message sending is done whilst mutating the receiver, see: SSheldon/rust-objc#112. We were effectively mutating behind either `&&mut T` or `&T`, where `T` is zero-sized and contains `UnsafeCell`, so while it is still uncertain exactly how much of an issue this actually is, the approach we use now is definitely sound! Also makes it clearer that `msg_send!` does not consume `Id`s, it only needs a reference to those.
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
2 times, most recently
from
June 6, 2022 16:57
7ba94f9
to
7a94811
Compare
If you do not want to consume it, the possibility of doing `msg_send![&*obj]` exists, but most of the time that is indeed what you want (I mean, why else would you wrap it in `ManuallyDrop`?)
madsmtm
force-pushed
the
msg-send-receiver-soundness
branch
from
June 6, 2022 16:58
7a94811
to
2beef61
Compare
This was referenced Jun 12, 2022
Closed
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Jul 20, 2022
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Jul 20, 2022
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Aug 28, 2022
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Aug 1, 2023
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Aug 1, 2023
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Aug 1, 2023
See madsmtm/objc2#150 for a bit of background
madsmtm
added a commit
to madsmtm/cacao
that referenced
this pull request
Sep 5, 2023
See madsmtm/objc2#150 for a bit of background
ryanmcgrath
pushed a commit
to ryanmcgrath/cacao
that referenced
this pull request
Sep 11, 2023
* Use objc2 * Replace `objc_id` * Remove sel_impl import * Fix `add_method` calls * Fix accessing raw FFI functions * Fix Encode impl * Fix message sends arguments that do not implement `Encode` * Use immutable reference in a few places where now necessary See madsmtm/objc2#150 for a bit of background * Add a few Send + Sync bounds where examples require it This is something we'll need to look into properly * Use `&'static Class` instead of `*const Class` Safer and more ergonomic. Also required for `msg_send_id!` macro * Use msg_send_id! and rc::Id * Update objc2 to v0.3.0-beta.2 * Replace `BOOL` with `Bool` when declaring delegates This makes cacao compile on Aarch64 again * Remove a few impossible to use correctly `into_inner` functions These consumed `self`, and hence also dropped `Id` variable that was responsible for keeping the returned pointer alive * Remove a few impossible to use correctly `From` implementations * Quickly fix UB with using BACKGROUND_COLOR ivar * Fix double-freeing of windows * Fix double freeing of strings * Fix a few remaining double-frees
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-objc2
Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates
bug
Something isn't working
help wanted
Extra attention is needed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves upstream issue SSheldon/rust-objc#112.
Whichever solution we choose has quite the large effect on #120, since we'd like
msg_send!
andmsg_send_id!
to be consistent, and e.g.msg_send_id!
sometimes needs the ability to consume its arguments.This PR is a stab at implementing idea 3 as outlined in SSheldon/rust-objc#112 (comment). Not quite happy with the fact that we use fully qualified method calls, which means reborrows are sometimes necessary (see diff in
objc2-foundation/src/array.rs
andobjc2-foundation/src/data.rs
, may or may not be a big problem in practice?).I'm reluctant to do idea 2 (add
msg_send_mut!
) since we would also needmsg_send_bool_mut!
andmsg_send_id_mut!
which is quite cumbersome!