Skip to content
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

Safer methods for wrapping CF references #185

Closed
burg opened this issue Nov 9, 2012 · 1 comment
Closed

Safer methods for wrapping CF references #185

burg opened this issue Nov 9, 2012 · 1 comment
Labels

Comments

@burg
Copy link

@burg burg commented Nov 9, 2012

I ran into a bug earlier where a CF wrapper in CoreText had accidentally called CFRelease on something that was not owned (i.e., followed the "Get" rule instead of "Copy" rule according to Core Foundation Ownership Rules). This is because it was wrapped without a call to CFRetain.

There are two ways to fix this, and each require separate wrap methods wrap_owned and wrap_borrowed. The simplest way is to call CFRetain for wrap_borrowed() and not wrap_owned(). This way, even non-owned things will have balanced refcounts when the wrapper is destroyed and calls CFRelease in the dtor.

The other option is to customize dtor behavior so that only owned CF references have their refcounts reduced, by parameterizing over WrapperType impl. This seems more complex, and is definitely not sound if we store the wrapper into a field somewhere---the owner of the reference could deallocate and leave the wrapper with a dangling pointer.

@burg
Copy link
Author

@burg burg commented Nov 16, 2012

Done!

@burg burg closed this Nov 16, 2012
ChrisParis pushed a commit to ChrisParis/servo that referenced this issue Sep 7, 2014
TestTWF, Asterisk-works: the test of input type=date
glennw pushed a commit to glennw/servo that referenced this issue Jan 16, 2017
Ensure that the render target cache doesn't return a render target that was allocated on this frame.

Fixes servo#185.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.