-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add all deserialization fatal output to the pretty stack trace #37743
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
@swift-ci please test |
Build failed |
126e03f
to
ae06648
Compare
@swift-ci please test |
Build failed |
Build failed |
os << "module '" << Name << "' with full misc version '" << MiscVersion | ||
<< "'"; | ||
if (Bits.IsAllowModuleWithCompilerErrorsEnabled) | ||
os << " (built while allowing compiler errors)"; |
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.
Could we use the flag instead here built with -experimental-allow-module-with-compiler-errors
? It would be more precise and we could add more relevant flags to it in the future.
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.
Sure, sounds good 👍
@@ -12,6 +12,7 @@ | |||
// CHECK: Stack dump: | |||
// CHECK-NEXT: Program arguments: | |||
// CHECK-NEXT: Swift version | |||
// CHECK-NEXT: Compiling with Swift version |
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.
This is part of the existing output right?
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.
No, which also answers your question below - the driver current outputs "Swift version ..." but does so before parsing any flags. I added a second version output after flags are passed so that we can pass in the effective version as well, which is the "Compiling with..." line (though note some tests are failing because apparently this can actually be Apple Swift sometimes).
I could remove the first version, but crashes during argument parsing would be missing the version then. Thoughts?
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 looks we only want the effective language version out of that line and from what I see swift::getSwiftFullVersion
directly prints the value of LangOpts.EffectiveLanguageVersion
. How about we bring that logic up and print the language version on its own line only if it's different than getCurrentLanguageVersion
?
void ModuleFileSharedCore::fatal(llvm::Error error) { | ||
logAllUnhandledErrors(std::move(error), llvm::errs(), | ||
"\n*** DESERIALIZATION FAILURE (please include this " | ||
"section in any bug report) ***\n"); |
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's a good change but I feel nostalgic with the idea of losing the part the nobody read (please include this section in any bug report)
!
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.
I think the main issue is that most of the time the compiler output wouldn't even be seen - ie. there'd be a crash and it gets reported based on the crash log and not the output.
lib/FrontendTool/FrontendTool.cpp
Outdated
os << "Compiling with " << | ||
version::getSwiftFullVersion(LangOpts.EffectiveLanguageVersion); | ||
if (LangOpts.AllowModuleWithCompilerErrors) | ||
os << " while allowing modules with compiler errors enabled"; |
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.
Here too we could list the flag instead.
} | ||
getContext().Diags.diagnose( | ||
SourceLoc(), diag::serialization_compatibility_version_mismatch, | ||
effectiveVersionBuffer, Core->Name, compatVersionBuffer); |
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.
Do we still have the information about the Swift language compatibility version of the module somewhere in the output? This note has been useful to me at least once to quickly explain a deserialization failure due to changes in ClangImporter behaviors between two Swift versions.
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.
See above re. the effective version, as an example output:
Stack dump:
0. Program arguments: ......
1. Swift version 5.5-dev (LLVM <hash>, Swift <hash>)
2. Compiling with Swift version 5.5-dev effective-4.2 (LLVM <hash>, Swift <hash>)
3. While evaluating request TypeCheckSourceFileRequest(source_file "<stdin>")
4. While type-checking statement at [<stdin>:1:13 - line:1:21] RangeText="_ = Sub."
5. While type-checking expression at [<stdin>:1:13 - line:1:21] RangeText="_ = Sub."
6. While evaluating request QualifiedLookupRequest(0x7fa27c81ce00 TopLevelCodeDecl line=1, {Lib.(file).Sub}, 'disappearingMethod', { NL_ProtocolMembers, NL_RemoveNonVisible, NL_RemoveOverridden, NL_OnlyTypes })
7. While evaluating request DirectLookupRequest(directly looking up 'disappearingMethod' on Lib.(file).Sub with options { })
8. While loading members for 'Sub' (in module 'Lib')
9. *** DESERIALIZATION FAILURE ***
module 'Lib' with full misc version '5.5(4.1.50)/Swift version 5.5-dev (LLVM <hash>, Swift <hash>)'
could not find 'disappearingMethod()' in parent class
So here we can see the version being compiled is effective-4.2
(2.) and the module was compiled with (4.1.50)
(9.)
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.
Thank you for this!
To give an example of the full stderr that's now output:
As I mentioned in one of the comments, I'm not a huge fan of doubling up the compiler version, @xymus do you think it's worth keeping the one before arguments are parsed? Also, assuming we have program arguments there's also the double up with the |
ae06648
to
452c3e4
Compare
@swift-ci please test |
Rather than outputting diagnostics and to stderr, output all the extra information added when deserialization fatally fails to the pretty stack trace instead. Since the pretty stack trace is added to crash logs, this should avoid the dance of requesting the compiler output - Moves the previous "**** DESERIALIZATION FAILURE ..." output to the last pretty stack trace line - Removes the module and compiler version notes added to the fatal diagnostic - Adds a new effective compiler version line for all frontend failure. Somewhat duplicates the line from the driver, but adds in the effective version - Adds a new line for the full misc version of the module that failed. May double up with previous "While reading from ..." lines that are added in various deserialization methods, but better to have it twice than not at all
452c3e4
to
599ba8b
Compare
Okay, changed to just give the effective version and removed the superfluous "-experimental-allow-module-with-errors":
@swift-ci please test |
Build failed |
@swift-ci please test macOS platform |
Rather than outputting diagnostics and to stderr, output all the extra
information added when deserialization fatally fails to the pretty stack
trace instead. Since the pretty stack trace is added to crash logs, this
should avoid the dance of requesting the compiler output
Moves the previous "**** DESERIALIZATION FAILURE ..." output to the
last pretty stack trace line
Removes the module and compiler version notes added to the fatal
diagnostic
Adds a new effective compiler version line for all frontend failure.
Somewhat duplicates the line from the driver, but adds in the
effective version
Adds a new line for the full misc version of the module that failed.
May double up with previous "While reading from ..." lines that are
added in various deserialization methods, but better to have it
twice than not at all