Skip to content

Conversation

vim-zz
Copy link

@vim-zz vim-zz commented Jul 21, 2025

✨ PR Description

Purpose: Fix edge case in Socket's _clear_io_state method by removing unnecessary file descriptor check that could prevent proper cleanup.
Main changes:

  • Removed redundant condition self._fd != -1 in _clear_io_state method to ensure proper socket resource cleanup

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Copy link

gitstream-cm bot commented Jul 21, 2025

Please mark which AI tools you used for this PR by checking the appropriate boxes:

  • GitHub Copilot
  • Cursor
  • ChatGPT
  • Tabnine
  • JetBrains AI Assistant
  • VSCode IntelliCode
  • Claude
  • Gemini
  • Other AI tool
  • No AI tools were used

Tip: If you want to avoid this comment in the future, you can add a label of the format 🤖 ai-* when creating your PR.

Copy link

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

The PR removes a file descriptor validity check from the cleanup logic. This could potentially cause issues when attempting to remove invalid file descriptors from the selector.

1 issues detected:

🐞 Bug - Calling `remove_reader()` with an invalid file descriptor (-1) may cause exceptions or selector state corruption.

Details: The removal of the self._fd != -1 condition allows the code to attempt removing an invalid file descriptor from the selector. This could cause exceptions or undefined behavior when the socket's file descriptor is already closed or invalid.
File: zmq/asyncio.py (160-160)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

"""
loop = self._current_loop
if loop and not loop.is_closed() and self._fd != -1:
if loop and not loop.is_closed():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Invalid File Descriptor: Restore the self._fd != -1 check in the condition to ensure only valid file descriptors are passed to remove_reader(), or add explicit validation before calling remove_reader().

Suggested change
if loop and not loop.is_closed():
if loop and not loop.is_closed() and self._fd != -1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant