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

Use CFRunLoopRemoveSourceInvalidate instead of CFRunLoopRemoveSource in CFReactor #6960

Closed
twisted-trac opened this issue Feb 10, 2014 · 3 comments

Comments

@twisted-trac
Copy link

BobNovas's avatar BobNovas reported
Trac ID trac#6960
Type defect
Created 2014-02-10 18:28:12Z

If you are using CFReactor, and doing your own IO (in particular, using
pybonjour and adding your file descriptor to the reactor's reader list
(e.g., reactor.addReader), then, if you close the file descriptor before
you call removeReader, on some platforms (Lion) you will likely wind up
in CFRunLoopRemoveSource in a spinlock waiting on the FD. The solution is
either to ensure that you call removeReader before closing the FD, or
CFReactor could solve the problem by using CFRunLoopRemoveSourceInvalidate
instead of CFRunLoopRemoveSource at line 300.

See http://icodeanswer1.appspot.com/post/709526 and attached crash
report.txt file.

Attachments:

  • crashreport.txt (64261 bytes) - added by BobNovas on 2014-02-10 18:29:26Z - Typical hang showing spinlock in CFRunLoopRemoveSource
Searchable metadata
trac-id__6960 6960
type__defect defect
reporter__BobNovas BobNovas
priority__normal normal
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__cfreactor__spin_lock__CFRunLoopRemoveSource cfreactor, spin lock, CFRunLoopRemoveSource
time__1392056892000000 1392056892000000
changetime__1392056892000000 1392056892000000
version__None None
owner__ 

@glyph
Copy link
Member

glyph commented Jan 12, 2024

Perhaps this is a clue to #11771 's cause

@glyph
Copy link
Member

glyph commented Jan 12, 2024

I think this is referring to CFRunLoopSourceInvalidate since there doesn't seem to be a CFRunLoopRemoveSourceInvalidate in the API

@glyph
Copy link
Member

glyph commented May 3, 2024

Given that this specifically mentions Lion, and we have tests for this sort of FD shenanigans for other platforms, I don't think that this report is necessarily valid any more. If this is still an issue I really hope someone will re-report it, but given how much I use CFReactor these days, I think I will eventually bump into it if so. (Although really, removeReader before closing the FD is really the application's responsibility, dealing with closed FDs like this can only be done heuristically.)

@glyph glyph closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants