* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
@ 2013-03-27 19:32 ` burnus at gcc dot gnu.org
2013-03-27 20:24 ` burnus at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-27 19:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to work| |4.3.4, 4.4.0
Keywords| |wrong-code
Last reconfirmed| |2013-03-27
CC| |burnus at gcc dot gnu.org,
| |jvdelisle at gcc dot
| |gnu.org
Ever Confirmed|0 |1
Summary|Bizarre Hollerith edit |[4.6/4.7/4.8/4.9
|descriptor errors (valgrind |Regression] Wrong I/O
|shows uninitialized value |result with format cache
|in libgfortran) |for Hollerith strings
Target Milestone|--- |4.6.4
Known to fail| |4.5.3, 4.6.3, 4.7.2, 4.8.0,
| |4.9.0
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-27 19:32:32 UTC ---
Seems to be a regression in libgfortran. It works with gfortran 4.3 and 4.4,
but fails with gfortran 4.5 to 4.9.
(Compiling with 4.9 and running with libgfortran 4.3 works, i.e. the regression
must be in libgfortran.)
It works if one disables the format cache.
If one adds some debugging output to write_constant_string, one sees that for
the second call, the delimiter (f->u.string.p[-1]) is not 'H' - and the first
6H is also wrong.
write_constant_string: len=1: f->u.string.p=' '- delim='H'
write_constant_string: len=1: f->u.string.p=' '- delim='H'
write_constant_string: len=1: f->u.string.p=' '- delim='H'
write_constant_string: len=6: f->u.string.p='===== '- delim='h'
write_constant_string: len=6: f->u.string.p=' ====='- delim='h'
===== end of level 1 =====
write_constant_string: len=1: f->u.string.p=' '- delim=' '
write_constant_string: len=1: f->u.string.p=' '- delim=' '
write_constant_string: len=1: f->u.string.p=' '- delim=' '
write_constant_string: len=6: f->u.string.p=' '- delim=' '
write_constant_string: len=6: f->u.string.p=' ====='- delim=' '
end of level 1 ====)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
2013-03-27 19:32 ` [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings burnus at gcc dot gnu.org
@ 2013-03-27 20:24 ` burnus at gcc dot gnu.org
2013-03-28 10:00 ` burnus at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-27 20:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-27 20:24:11 UTC ---
If one sets the breakpoint in _gfortrani_next_format, one gets for the
original, non cached version:
(gdb) p dtp->u.p.fmt.array.array[1].source
$13 = 0x7fffffffdec6 "1H ),6h===== ,a 12,i4,6h =====)", ...
For the second round, one gets:
(gdb) p dtp->u.p.fmt.array.array[1].source
$14 = 0x7fffffffdec6 ' ' <repeats 26 times>, "=====) \f"
Thus, the "source" string is not carried over.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
2013-03-27 19:32 ` [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings burnus at gcc dot gnu.org
2013-03-27 20:24 ` burnus at gcc dot gnu.org
@ 2013-03-28 10:00 ` burnus at gcc dot gnu.org
2013-03-29 9:38 ` burnus at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-28 10:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |burnus at gcc dot gnu.org
|gnu.org |
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-28 10:00:42 UTC ---
(In reply to comment #3)
> Note the comment at line 728 of format.c where we must disable format caching
> when we encounter FMT_STRING. The problem is related to saving a pointer to a
> string rather than the string itself. That pointer can go out of scope on
> subsequent I/O operations so caching the format data will not work.
Well, one could save the data. The string is also stored in the hash:
u->format_hash_table[hash].key = xmalloc (dtp->format_len);
memcpy (u->format_hash_table[hash].key, dtp->format, dtp->format_len);
Thus, instead of saving it after the parsing as key, one can duplicate the
string and store it as dtp->format before parsing the string.
That's what I do in the patch, submitted at:
http://gcc.gnu.org/ml/fortran/2013-03/msg00155.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (2 preceding siblings ...)
2013-03-28 10:00 ` burnus at gcc dot gnu.org
@ 2013-03-29 9:38 ` burnus at gcc dot gnu.org
2013-03-29 9:40 ` burnus at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-29 9:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-29 09:38:20 UTC ---
Author: burnus
Date: Fri Mar 29 09:37:37 2013
New Revision: 197229
URL: http://gcc.gnu.org/viewcvs?rev=197229&root=gcc&view=rev
Log:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format): With caching, copy
dtp->format string.
(save_parsed_format): Use dtp->format directly without
copying.
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* testsuite/gfortran.dg/fmt_cache_3.f90: New.
(Plus: Move fortran/ChangeLog item to libgfortran/ChangeLog)
Added:
trunk/gcc/testsuite/gfortran.dg/fmt_cache_3.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/format.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (3 preceding siblings ...)
2013-03-29 9:38 ` burnus at gcc dot gnu.org
@ 2013-03-29 9:40 ` burnus at gcc dot gnu.org
2013-04-02 15:43 ` burnus at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-03-29 9:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-03-29 09:40:13 UTC ---
Author: burnus
Date: Fri Mar 29 09:39:47 2013
New Revision: 197230
URL: http://gcc.gnu.org/viewcvs?rev=197230&root=gcc&view=rev
Log:
2012-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format_list): Also cache FMT_STRING.
(parse_format): Update call.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/format.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (4 preceding siblings ...)
2013-03-29 9:40 ` burnus at gcc dot gnu.org
@ 2013-04-02 15:43 ` burnus at gcc dot gnu.org
2013-04-03 10:15 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-02 15:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-02 15:43:19 UTC ---
Author: burnus
Date: Tue Apr 2 15:42:31 2013
New Revision: 197359
URL: http://gcc.gnu.org/viewcvs?rev=197359&root=gcc&view=rev
Log:
libgfortran/
2013-04-02 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format): With caching, copy
dtp->format string.
(save_parsed_format): Use dtp->format directly without
copying.
2012-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format_list): Also cache FMT_STRING.
(parse_format): Update call.
gcc/testsuite/
2013-04-02 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* testsuite/gfortran.dg/fmt_cache_3.f90: New.
Added:
branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/fmt_cache_3.f90
Modified:
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
branches/gcc-4_8-branch/libgfortran/ChangeLog
branches/gcc-4_8-branch/libgfortran/io/format.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (5 preceding siblings ...)
2013-04-02 15:43 ` burnus at gcc dot gnu.org
@ 2013-04-03 10:15 ` rguenth at gcc dot gnu.org
2013-04-03 14:02 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-03 10:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (6 preceding siblings ...)
2013-04-03 10:15 ` rguenth at gcc dot gnu.org
@ 2013-04-03 14:02 ` burnus at gcc dot gnu.org
2013-04-03 14:07 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-03 14:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-03 14:02:36 UTC ---
Author: burnus
Date: Wed Apr 3 14:00:20 2013
New Revision: 197412
URL: http://gcc.gnu.org/viewcvs?rev=197412&root=gcc&view=rev
Log:
2013-04-03 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format): With caching, copy
dtp->format string.
(save_parsed_format): Use dtp->format directly without
copying.
2013-04-03 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* testsuite/gfortran.dg/fmt_cache_3.f90: New.
Added:
branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/fmt_cache_3.f90
Modified:
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
branches/gcc-4_7-branch/libgfortran/ChangeLog
branches/gcc-4_7-branch/libgfortran/io/format.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (7 preceding siblings ...)
2013-04-03 14:02 ` burnus at gcc dot gnu.org
@ 2013-04-03 14:07 ` burnus at gcc dot gnu.org
2013-04-04 9:32 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-03 14:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-03 14:07:02 UTC ---
(In reply to comment #8)
> 2013-04-03 Tobias Burnus <burnus@net-b.de>
>
> Backport from mainline:
> 2013-03-29 Tobias Burnus <burnus@net-b.de>
>
> PR fortran/56737
> * io/format.c (parse_format): With caching, copy
> dtp->format string.
> (save_parsed_format): Use dtp->format directly without
> copying.
I forgot to include the following bits in the commit log - it's in the
ChangeLog and in the commit:
> 2012-03-29 Tobias Burnus <burnus@net-b.de>
>
> PR fortran/56737
> * io/format.c (parse_format_list): Also cache FMT_STRING.
> (parse_format): Update call.
So far, the issue is fixed on the trunk and the 4.7 and 4.8 branches; GCC 4.7.3
is scheduled to be released in the next days. (Backporting to 4.6 is still
pending.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (8 preceding siblings ...)
2013-04-03 14:07 ` burnus at gcc dot gnu.org
@ 2013-04-04 9:32 ` burnus at gcc dot gnu.org
2013-04-04 9:38 ` burnus at gcc dot gnu.org
2013-04-04 10:43 ` jonathan.hogg at stfc dot ac.uk
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-04 9:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-04 09:32:14 UTC ---
Author: burnus
Date: Thu Apr 4 09:31:53 2013
New Revision: 197474
URL: http://gcc.gnu.org/viewcvs?rev=197474&root=gcc&view=rev
Log:
libgfortran/
2013-04-04 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format): With caching, copy
dtp->format string.
(save_parsed_format): Use dtp->format directly without
copying.
2012-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* io/format.c (parse_format_list): Also cache FMT_STRING.
(parse_format): Update call.
gcc/testsuite/
2013-04-04 Tobias Burnus <burnus@net-b.de>
Backport from mainline:
2013-03-29 Tobias Burnus <burnus@net-b.de>
PR fortran/56737
* testsuite/gfortran.dg/fmt_cache_3.f90: New.
Added:
branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/fmt_cache_3.f90
Modified:
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
branches/gcc-4_6-branch/libgfortran/ChangeLog
branches/gcc-4_6-branch/libgfortran/io/format.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (9 preceding siblings ...)
2013-04-04 9:32 ` burnus at gcc dot gnu.org
@ 2013-04-04 9:38 ` burnus at gcc dot gnu.org
2013-04-04 10:43 ` jonathan.hogg at stfc dot ac.uk
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-04 9:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-04 09:38:53 UTC ---
FIXED on the 4.9 trunk - and on the 4.6, 4.7 and 4.8 branches.
The very soon to be released 4.7.3 and 4.6.4 will contain this fix. (As will
4.8.1, but that take still a while.)
Thanks for the bug report - and sorry for the regression.
You could either upgrade to one of those, e.g. Ubuntu might provide a 4.7.3 in
a few weeks via PPA, cf. http://gcc.gnu.org/wiki/GFortranDistros
Or you build it yourself or use an unofficial binary build, cf.
http://gcc.gnu.org/wiki/GFortranBinaries
Or you replace the H9Hollerith strings by "normal" 'strings' in I/O fmts.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libfortran/56737] [4.6/4.7/4.8/4.9 Regression] Wrong I/O result with format cache for Hollerith strings
2013-03-26 11:46 [Bug libfortran/56737] New: Bizarre Hollerith edit descriptor errors (valgrind shows uninitialized value in libgfortran) jonathan.hogg at stfc dot ac.uk
` (10 preceding siblings ...)
2013-04-04 9:38 ` burnus at gcc dot gnu.org
@ 2013-04-04 10:43 ` jonathan.hogg at stfc dot ac.uk
11 siblings, 0 replies; 13+ messages in thread
From: jonathan.hogg at stfc dot ac.uk @ 2013-04-04 10:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56737
--- Comment #12 from Jonathan Hogg <jonathan.hogg at stfc dot ac.uk> 2013-04-04 10:43:02 UTC ---
Thanks for fixing this. The code in question has been moved to use 'strings'
rather than Hollerith i/o - we aim for it to be F95 compliant anyway!
Jonathan.
^ permalink raw reply [flat|nested] 13+ messages in thread