Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix CFRunLoop types to avoid UB #349
Merged
+37
−38
Conversation
A number of callback functions associated with the CFRunLoop types are allowed to be NULL to evoke default behavior. Prior to this commit the definition of those structs prevented passing in null which meant resorting to transmute or other tricks to effectively set null, but with recent compiler versions the compiler emits `ud2` instructions and triggers a fault at runtime. The correct resolution for this is to define these fields as `Option`al callbacks and that is what this commit does. I've used this approach successfully here in another project: Refs: wez/wezterm@398f333 I've bumped up the version for the crate as part of this commit because it effectively changes the API around these structs.
|
Since the definition of |
|
Thanks for fixing this! |
|
@bors-servo r+ |
|
|
bors-servo
added a commit
that referenced
this pull request
Nov 12, 2019
Fix CFRunLoop types to avoid UB A number of callback functions associated with the CFRunLoop types are allowed to be NULL to evoke default behavior. Prior to this commit the definition of those structs prevented passing in null which meant resorting to transmute or other tricks to effectively set null, but with recent compiler versions the compiler emits `ud2` instructions and triggers a fault at runtime. The correct resolution for this is to define these fields as `Option`al callbacks and that is what this commit does. I've used this approach successfully here in another project: Refs: wez/wezterm@398f333 I've bumped up the version for the crate as part of this commit because it effectively changes the API around these structs.
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
wez commentedNov 12, 2019
A number of callback functions associated with the CFRunLoop types are
allowed to be NULL to evoke default behavior.
Prior to this commit the definition of those structs prevented passing
in null which meant resorting to transmute or other tricks to
effectively set null, but with recent compiler versions the compiler
emits
ud2instructions and triggers a fault at runtime.The correct resolution for this is to define these fields as
Optionalcallbacks and that is what this commit does.
I've used this approach successfully here in another project:
Refs: wez/wezterm@398f333
I've bumped up the version for the crate as part of this commit
because it effectively changes the API around these structs.