-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[flang] Fix crash under -fdebug-dump-all #66224
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
flang:driver
flang
Flang issues not falling into any other category
flang:semantics
labels
Sep 13, 2023
@llvm/pr-subscribers-flang-driver @llvm/pr-subscribers-flang-semantics ChangesThe -fdebug-dump-all flag invokes runtime type information generation even for a program with fatal semantic errors. This could cause a crash on a failed CHECK(), since the type information table generator assumes a correct program. Make it more resilient for a known fatal case. (But if we hit many more of these, we should look into not generating the runtime type information tables under this flag.) -- Full diff: https://github.com//pull/66224.diff2 Files Affected:
diff --git a/flang/lib/Semantics/runtime-type-info.cpp b/flang/lib/Semantics/runtime-type-info.cpp index c46b12d6b30e86e..aa470ecdc771941 100644 --- a/flang/lib/Semantics/runtime-type-info.cpp +++ b/flang/lib/Semantics/runtime-type-info.cpp @@ -310,8 +310,11 @@ static SomeExpr StructureExpr(evaluate::StructureConstructor &&x) { static int GetIntegerKind(const Symbol &symbol) { auto dyType{evaluate::DynamicType::From(symbol)}; - CHECK(dyType && dyType->category() == TypeCategory::Integer); - return dyType->kind(); + CHECK((dyType && dyType->category() == TypeCategory::Integer) || + symbol.owner().context().HasError(symbol)); + return dyType && dyType->category() == TypeCategory::Integer + ? dyType->kind() + : symbol.owner().context().GetDefaultKind(TypeCategory::Integer); } // Save a rank-1 array constant of some numeric type as an diff --git a/flang/test/Driver/dump-all-bad.f90 b/flang/test/Driver/dump-all-bad.f90 index 2d6f71a526af5b5..58f0d02c497469d 100644 --- a/flang/test/Driver/dump-all-bad.f90 +++ b/flang/test/Driver/dump-all-bad.f90 @@ -10,6 +10,8 @@ ! CHECK: Flang: symbols dump program bad - real,pointer :: x - x = null() ! Error - must be pointer assignment + type dt(k) + integer(kind=16) :: k + integer(kind=16) :: comp + end type dt end |
The -fdebug-dump-all flag invokes runtime type information generation even for a program with fatal semantic errors. This could cause a crash on a failed CHECK(), since the type information table generator assumes a correct program. Make it more resilient for a known fatal case. (But if we hit many more of these, we should look into not generating the runtime type information tables under this flag.) Pull request: llvm#66224
psteinfeld
approved these changes
Sep 13, 2023
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.
Thanks for fixing this!
banach-space
approved these changes
Sep 13, 2023
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.
LGTM, thanks!
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
The -fdebug-dump-all flag invokes runtime type information generation even for a program with fatal semantic errors. This could cause a crash on a failed CHECK(), since the type information table generator assumes a correct program. Make it more resilient for a known fatal case. (But if we hit many more of these, we should look into not generating the runtime type information tables under this flag.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The -fdebug-dump-all flag invokes runtime type information generation even for a program with fatal semantic errors. This could cause a crash on a failed CHECK(), since the type information table generator assumes a correct program. Make it more resilient for a known fatal case. (But if we hit many more of these, we should look into not generating the runtime type information tables under this flag.)