Skip to content

[flang][runtime] Clear leftTabLimit at in FinishReadingRecord #98822

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

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

klausler
Copy link
Contributor

ExternalFileUnit::FinishReadingRecord() is called at the end of a READ statement, unless the read is non-advancing and there was no error. In the event of an erroneous non-advancing read, however, FinishReadingRecord() leaves ConnectionState::leftTabLimit inhabited by a value, leaving the impression that the next record is undergoing a non-advancing operation, and this cause the next operation to fail. In the test case in the reported bug, the next operation is a BACKSPACE, and it ends up doing nothing. The fix is to always reset leftTabLimit in FinishReadingRecord.

Fixes #98783.

ExternalFileUnit::FinishReadingRecord() is called at the end of
a READ statement, unless the read is non-advancing and there was
no error.  In the event of an erroneous non-advancing read,
however, FinishReadingRecord() leaves ConnectionState::leftTabLimit
inhabited by a value, leaving the impression that the *next*
record is undergoing a non-advancing operation, and this cause
the next operation to fail.  In the test case in the reported
bug, the next operation is a BACKSPACE, and it ends up doing
nothing.  The fix is to always reset leftTabLimit in
FinishReadingRecord.

Fixes llvm#98783.
@klausler klausler requested a review from vdonaldson July 14, 2024 16:32
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Jul 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 14, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

ExternalFileUnit::FinishReadingRecord() is called at the end of a READ statement, unless the read is non-advancing and there was no error. In the event of an erroneous non-advancing read, however, FinishReadingRecord() leaves ConnectionState::leftTabLimit inhabited by a value, leaving the impression that the next record is undergoing a non-advancing operation, and this cause the next operation to fail. In the test case in the reported bug, the next operation is a BACKSPACE, and it ends up doing nothing. The fix is to always reset leftTabLimit in FinishReadingRecord.

Fixes #98783.


Full diff: https://github.com/llvm/llvm-project/pull/98822.diff

1 Files Affected:

  • (modified) flang/runtime/unit.cpp (+1)
diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp
index a11f444d8d754..5c5bca835f3d8 100644
--- a/flang/runtime/unit.cpp
+++ b/flang/runtime/unit.cpp
@@ -268,6 +268,7 @@ void ExternalFileUnit::FinishReadingRecord(IoErrorHandler &handler) {
     recordOffsetInFrame_ = 0;
   }
   BeginRecord();
+  leftTabLimit.reset();
 }
 
 bool ExternalFileUnit::AdvanceRecord(IoErrorHandler &handler) {

@klausler klausler merged commit 2027857 into llvm:main Jul 18, 2024
10 checks passed
@klausler klausler deleted the bug98783 branch July 18, 2024 22:35
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
ExternalFileUnit::FinishReadingRecord() is called at the end of a READ
statement, unless the read is non-advancing and there was no error. In
the event of an erroneous non-advancing read, however,
FinishReadingRecord() leaves ConnectionState::leftTabLimit inhabited by
a value, leaving the impression that the *next* record is undergoing a
non-advancing operation, and this cause the next operation to fail. In
the test case in the reported bug, the next operation is a BACKSPACE,
and it ends up doing nothing. The fix is to always reset leftTabLimit in
FinishReadingRecord.

Fixes #98783.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251364
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flang] backspace after non-advancing read
3 participants