Skip to content

Fix issue with double-opening temp corpus files#5342

Merged
aakallam merged 1 commit into
masterfrom
push-mvrmnzpkqykw
Jul 1, 2026
Merged

Fix issue with double-opening temp corpus files#5342
aakallam merged 1 commit into
masterfrom
push-mvrmnzpkqykw

Conversation

@aakallam

Copy link
Copy Markdown
Collaborator

It is fine for Linux and Mac bots to create multiple file objects to the same on-disk file but Windows does not allow this and throws a PermissionError for any attempts to open a file that is already opened.

This slightly refactors src/clusterfuzz/_internal/google_cloud_utils/storage.py (and its callers) to allow passing a filepath or file object when downloading from signed URLs and changes src/clusterfuzz/_internal/fuzzing/corpus_manager.py to use the file-based method.

Bug: crbug.com/529346593

@aakallam aakallam requested a review from a team as a code owner June 30, 2026 17:59
@aakallam aakallam force-pushed the push-mvrmnzpkqykw branch 4 times, most recently from 4881b96 to d16eca9 Compare June 30, 2026 18:31
storage.download_signed_url_to_file(corpus.backup_url,
temp_zipfile.name)
storage.download_signed_url_to_file(corpus.backup_url, temp_zipfile)
with archive.open(temp_zipfile.name) as reader:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure, but since temp_zipfile is still held open, wouldn't this line try to reopen it by name and potentially face the same error?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No because I have changed storage.download_signed_url_to_file() to take a file object and simply write to it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see, but I'm wondering about the very next line: with archive.open(temp_zipfile.name). Won't this try to open the file by name again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah sorry, I read through your comment in my email, missed which line you were talking about and completely misunderstood!

You are right that trying to read the zip would throw a similar error so I have refactored that bit as well. There wasn't a super clean way to fix that but I'm hoping my solution is the least error-prone way to handle it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch!

@aakallam aakallam force-pushed the push-mvrmnzpkqykw branch from d16eca9 to eb06917 Compare July 1, 2026 14:31
It is fine for Linux and Mac bots to create multiple file objects to the same on-disk file but Windows does not allow this and throws a PermissionError. This slightly refactors storage.py to allow passing a filepath or file object when downloading from signed URLs.
@aakallam aakallam force-pushed the push-mvrmnzpkqykw branch from eb06917 to c82c657 Compare July 1, 2026 15:18

@PauloVLB PauloVLB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

This will be deployed in today’s release, so let’s keep track of the results.

@aakallam aakallam merged commit be0597a into master Jul 1, 2026
14 of 15 checks passed
@aakallam aakallam deleted the push-mvrmnzpkqykw branch July 1, 2026 15:46
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.

3 participants