Skip to content

Fix mmap aborting with invalid fd in debug mode #5727

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

Merged
merged 1 commit into from
Apr 21, 2025

Conversation

xbjfk
Copy link
Contributor

@xbjfk xbjfk commented Apr 21, 2025

When running test_mmap without release, it fails with a safety violation. This is because File::from_raw_fd is called from an invalid fd (the one from python). Instead, to fix this while avoiding TOCTOU, use fstat from the nix crate instead

test_bad_file_desc (test.test_mmap.MmapTests.test_bad_file_desc) ... fatal runtime error: IO Safety violation: owned file descriptor already closed
zsh: abort      cargo run -- -m test test_mmap -v

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Thanks, it looks better. Thank you for contributing!

@youknowone youknowone merged commit ecbc6f7 into RustPython:main Apr 21, 2025
11 checks passed
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.

2 participants