public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer
@ 2024-05-13 0:12 dramwang at 163 dot com
2024-05-15 11:26 ` [Bug modula2/115057] " gaius at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dramwang at 163 dot com @ 2024-05-13 0:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057
Bug ID: 115057
Summary: TextIO.ReadRestLine raise an exception for
insufficient buffer
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: modula2
Assignee: gaius at gcc dot gnu.org
Reporter: dramwang at 163 dot com
Target Milestone: ---
For following code, `ReadRestLine` will raise an "attempting to read beyond end
of file" exception, which I think is incorrect:
```
MODULE test ;
IMPORT SeqFile, TextIO ;
VAR
chan : SeqFile.ChanId ;
line : ARRAY [0..5] OF CHAR ;
results : SeqFile.OpenResults ;
BEGIN
SeqFile.OpenRead (chan, "test.mod", SeqFile.read, results) ;
TextIO.ReadRestLine (chan, line) ;
END test.
```
Tested on Debian 12, with GCC 15.0.0 20240509 (83fb5e6):
```
% gm2 test.mod && ./a.out
EXCEPTIONS.mod:65:56: In RAISE
EXCEPTIONS.mod:65:56:attempting to read beyond end of file
Aborted
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/115057] TextIO.ReadRestLine raise an exception for insufficient buffer
2024-05-13 0:12 [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer dramwang at 163 dot com
@ 2024-05-15 11:26 ` gaius at gcc dot gnu.org
2024-05-15 15:02 ` gaius at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-15 11:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2024-05-15
--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed thanks for the bug report.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/115057] TextIO.ReadRestLine raise an exception for insufficient buffer
2024-05-13 0:12 [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer dramwang at 163 dot com
2024-05-15 11:26 ` [Bug modula2/115057] " gaius at gcc dot gnu.org
@ 2024-05-15 15:02 ` gaius at gcc dot gnu.org
2024-05-15 15:59 ` cvs-commit at gcc dot gnu.org
2024-05-15 15:59 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-15 15:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057
--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 58214
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58214&action=edit
Proposed fix
Here is a proposed fix - which I'll commit (if/when) a full bootstrap
completes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/115057] TextIO.ReadRestLine raise an exception for insufficient buffer
2024-05-13 0:12 [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer dramwang at 163 dot com
2024-05-15 11:26 ` [Bug modula2/115057] " gaius at gcc dot gnu.org
2024-05-15 15:02 ` gaius at gcc dot gnu.org
@ 2024-05-15 15:59 ` cvs-commit at gcc dot gnu.org
2024-05-15 15:59 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-15 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:
https://gcc.gnu.org/g:680af0e1e90d4b80260d173636dfe15654fd470d
commit r15-516-g680af0e1e90d4b80260d173636dfe15654fd470d
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Wed May 15 16:58:21 2024 +0100
PR modula2/115057 TextIO.ReadRestLine raises an exception when buffer is
exceeded
TextIO.ReadRestLine will raise an "attempting to read beyond end of file"
exception if the buffer is exceeded. This bug is caused by the
TextIO.ReadRestLine calling IOChan.Skip without a preceeding IOChan.Look.
The Look procedure will update the status result whereas
Skip always sets read result to allRight.
gcc/m2/ChangeLog:
PR modula2/115057
* gm2-libs-iso/TextIO.mod (ReadRestLine): Use ReadChar to
skip unwanted characters as this calls IOChan.Look and updates
the cid result status. A Skip without a Look does not update
the status. Skip always sets read result to allRight.
* gm2-libs-iso/TextUtil.def (SkipSpaces): Improve comments.
(CharAvailable): Improve comments.
* gm2-libs-iso/TextUtil.mod (SkipSpaces): Improve comments.
(CharAvailable): Improve comments.
gcc/testsuite/ChangeLog:
PR modula2/115057
* gm2/isolib/run/pass/testrestline.mod: New test.
* gm2/isolib/run/pass/testrestline2.mod: New test.
* gm2/isolib/run/pass/testrestline3.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug modula2/115057] TextIO.ReadRestLine raise an exception for insufficient buffer
2024-05-13 0:12 [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer dramwang at 163 dot com
` (2 preceding siblings ...)
2024-05-15 15:59 ` cvs-commit at gcc dot gnu.org
@ 2024-05-15 15:59 ` gaius at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-15 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115057
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing - thanks again for the bug report.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-15 15:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13 0:12 [Bug modula2/115057] New: TextIO.ReadRestLine raise an exception for insufficient buffer dramwang at 163 dot com
2024-05-15 11:26 ` [Bug modula2/115057] " gaius at gcc dot gnu.org
2024-05-15 15:02 ` gaius at gcc dot gnu.org
2024-05-15 15:59 ` cvs-commit at gcc dot gnu.org
2024-05-15 15:59 ` gaius at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).