-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Enhance error diagnostics in bundle extraction when fwrite fails #120677
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
Conversation
Co-authored-by: agocke <[email protected]>
{ | ||
CompressionNative_InflateEnd(&zStream); | ||
trace::error(_X("I/O failure when writing decompressed file.")); | ||
if (ferror(file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like ferror
sets errno. But it looks like fwrite
almost always does. Let's just print errno in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to always print errno without checking ferror. Commit: 5b4f0d2
{ | ||
trace::error(_X("Failure extracting contents of the application bundle. Expected size:%" PRId64 " Actual size:%zu"), size, extracted_size); | ||
trace::error(_X("I/O failure when writing extracted files.")); | ||
if (ferror(file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to always print errno without checking ferror. Commit: 5b4f0d2
} | ||
|
||
fclose(file); | ||
if (fclose(file) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ignore fclose failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed fclose error checking. Commit: 5b4f0d2
@copilot please address comments |
Co-authored-by: agocke <[email protected]>
Closing as I don't think there's a reliable way to view this error code for all platforms. Can't find a guarantee that errno is set |
Summary
This PR enhances error diagnostics in bundle extraction to provide actionable information when I/O failures occur during file extraction. Previously, the code only checked if the extracted size didn't match the expected size and emitted generic error messages. Now, it provides detailed diagnostics to help troubleshoot disk full, quota exceeded, permission denied, or hardware errors.
Changes
Enhanced error handling in
src/native/corehost/bundle/extractor.cpp
:Added errno checking: Included
<cerrno>
to enable system error code inspectionEnhanced fwrite error handling for both compressed and non-compressed extraction paths:
strerror(errno)
when fwrite failsExample Error Messages
Before
After - Disk Full
After - Permission Denied
After - Compressed File Write Failure
Benefits
Testing
./build.sh clr+libs+host -rc release
./build.sh host.tests -rc release -test
Fixes #
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.