-
Notifications
You must be signed in to change notification settings - Fork 13k
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
regression: ArArchiveBuilder can no longer handle output to temporary files managed by Python #131896
Comments
Might have meant #122723 |
My bad, copy-pasted monched one character. #122723 is the one. |
My suggestion would be to essentially revert it for Windows only (i.e. use cc @bjorn3 |
Why is the temporary directory created in |
@bjorn3 did you mean my snippet? Python's The issue here is that you can rename open files in Linux (I think it's because you can always keep references to a deleted inode), whereas this is not possible on Windows, at least with Python's way of opening the handle. This did not happen previously because the file can still be written to. |
It has an optional Dir argument: https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryFile |
I missed your python snippet. I assumed what happened was: You tell rustc to output somewhere on a filesystem other than C:. Rustc decides to create a temporary directory in C: and then fails to do a cross-filesystem rename, in which case the step where rustc decides to create a temporary directory in C: shouldn't happen. I now see that the issue is with the output file you specified currently being open by another process, which on Windows would require either renaming the existing file before renaming the temp file to the specified output path or overwriting the existing output file. Before my PR the latter was presumably done. This is not correct behavior however as it would make it possible for other rustc invocations to accidentally see partially written output, which can cause corruption of their output or crashes. As such renaming the old file on windows or declaring that the python snippet you wrote should not work (and you need to either close the temp file first without deleting it before calling rustc or open it with the flag that allows deletion while it is still open) are the only acceptable options I think. |
Starting with rust 1.82 the internal rustc call fails with: failed to rename archive file: Access is denied. (os error 5) For some reason rust doesn't like Python having the file open while it tries to write to it (or replace it). See upstream issue: rust-lang/rust#131896 Work around by creating a temporary file and closing the handle before calling into rust, and deleting the file at the end. This could also be done with NamedTemporaryFile() by passing delete_on_close=False to it and using it as a context manager, but that only works since Python 3.12. Fixes #1134
It's failing due to rust-lang/rust#131896 - we can either pin a rustc version or wait until this issue is fixed; I hope upstream will give it a high priority. Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/1039>
Starting with rust 1.82 the internal rustc call fails with: failed to rename archive file: Access is denied. (os error 5) For some reason rust doesn't like Python having the file open while it tries to write to it (or replace it). See upstream issue: rust-lang/rust#131896 Work around by creating a temporary file and closing the handle before calling into rust, and deleting the file at the end. This could also be done with NamedTemporaryFile() by passing delete_on_close=False to it and using it as a context manager, but that only works since Python 3.12. Fixes #1134 Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/1040>
Code
I tried this code:
I expected to see this happen:
Instead, this happened:
This breaks librsvg building on MSVC, because I use this technique to query the
native-static-libs
for the Meson dependency setup.I traced the issue to the following pull request: #122723
Version it worked on
It most recently worked on: 1.77.2
Version with regression
rustc --version --verbose
:Backtrace
N/A
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
cc @sdroege @nirbheek @federicomenaquintero
The text was updated successfully, but these errors were encountered: