Skip to content

Fix infinite recursion risk in ImageDataset error handling #2508

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

Fix infinite recursion risk in ImageDataset error handling

Changes

  • Added maximum retry limit to prevent infinite recursion when loading corrupted/missing files
  • Improved error messages and logging for better diagnostics
  • Separated file access errors from image loading errors
  • Enhanced error recovery with proper state management

Impact

  • More reliable dataset loading
  • Better error diagnostics
  • Prevents potential infinite recursion edge cases
  • Maintains backward compatibility

Enhanced the error handling in ImageDataset.__getitem__ to prevent potential infinite recursion when loading corrupted or missing image files. The changes include:

Added a maximum retry limit based on dataset size
Improved error messages and logging
Better separation of file access and image loading errors
More robust error recovery with proper state management
This makes the dataset loading more reliable and provides better diagnostics when issues occur.
### Changes
- Added proper cleanup of tarfile objects to prevent file descriptor leaks
- Improved error handling with more descriptive messages
- Added worker safety for multi-process DataLoader scenarios
- Enhanced file handling to read and close files immediately

### Impact
- Prevents resource leaks during training with tar-based datasets
- Makes error messages more actionable
- Improves stability in multi-worker data loading
- Maintains backward compatibility while being more robust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant