public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/28747]  New: Empty write STREAM I/O file positioning problem
@ 2006-08-16  3:12 jvdelisle at gcc dot gnu dot org
  2006-08-18 16:08 ` [Bug libfortran/28747] " jvdelisle at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-16  3:12 UTC (permalink / raw)
  To: gcc-bugs

The following does not work with bleeding edge FreeBSD:

program streamtest
  implicit none
  character(1)   :: lf = char(10)
  character(1)   :: tchar
  integer        :: i,j,k
  real(kind=4), dimension(100,100) :: anarray
  open(10, file="teststream", access="stream", form="unformatted")
  anarray = 3.14159
  write(10) anarray
  anarray = 0.0
  write(10, pos=1) ! This should position for the following read
  read(10) anarray
  anarray = abs(anarray - 3.14159)
  if (any(anarray.gt.0.00001)) call abort()
  close(10,status="delete")
end program streamtest


-- 
           Summary: Empty write STREAM I/O file positioning problem
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jvdelisle at gcc dot gnu dot org
  GCC host triplet: FreeBSD


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
@ 2006-08-18 16:08 ` jvdelisle at gcc dot gnu dot org
  2006-08-18 16:12 ` jvdelisle at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-18 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jvdelisle at gcc dot gnu dot org  2006-08-18 16:08 -------
Created an attachment (id=12093)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12093&action=view)
assembly output for reduced case

There is wrong code generated setting up the parameters for the second call to
write.  The pointers are off by 400.  You can see this by comparing the
instructions just before the first call too _gfortran_st_write vs the
instructions leading up to the second _gfortran_st_write.

-fdump-tree-original looks OK.  Inserting a flush right after the first call to
write in the test case and the problem goes away.

Middle-end or backend problem?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
  2006-08-18 16:08 ` [Bug libfortran/28747] " jvdelisle at gcc dot gnu dot org
@ 2006-08-18 16:12 ` jvdelisle at gcc dot gnu dot org
  2006-08-18 16:15 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-18 16:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2006-08-18 16:12 -------
Simplified test case used in discussion above.

program streamtest
  implicit none
  real, dimension(2,3) :: anarray
  open(10, file="teststream", access="stream", form="unformatted")
  anarray = 3.14159
  write(10) anarray
  !flush(10)
  write(10, pos=1) ! This is a way to position an unformatted file
  anarray = 0.0
  read(10) anarray
  close(10,status="keep")
end program streamtest

Additional info:

Using built-in specs.
Target: x86_64-unknown-freebsd7.0
Configured with: ../gcc4x/configure --prefix=/home/sgk/work/4x
--enable-languages=c,fortran
Thread model: posix
gcc version 4.2.0 20060816 (experimental)


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|FreeBSD                     |x86_64-unknown-freebsd7.0
 GCC target triplet|                            |x86_64-unknown-freebsd7.0
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
  2006-08-18 16:08 ` [Bug libfortran/28747] " jvdelisle at gcc dot gnu dot org
  2006-08-18 16:12 ` jvdelisle at gcc dot gnu dot org
@ 2006-08-18 16:15 ` pinskia at gcc dot gnu dot org
  2006-08-18 16:30 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-18 16:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-08-18 16:15 -------
(In reply to comment #1)
> Middle-end or backend problem?
Can you look at the dump that is produced by -fdump-tree-final_cleanup
and see if it is correct?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-08-18 16:15 ` pinskia at gcc dot gnu dot org
@ 2006-08-18 16:30 ` jvdelisle at gcc dot gnu dot org
  2006-08-18 20:54 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-18 16:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2006-08-18 16:29 -------
Using -fdump-tree-final_cleanup all looks OK.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-08-18 16:30 ` jvdelisle at gcc dot gnu dot org
@ 2006-08-18 20:54 ` jvdelisle at gcc dot gnu dot org
  2006-08-19  3:29 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-18 20:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2006-08-18 20:54 -------
Here is a debug trace showing the steps leading up to the mutation of the dtp
pointer.  StevebB on IRC indicated that the assembly output on linux x86-64
natch the freebsd version I posted here and the problem does not occur on that
platform.  Notice the before an after values of the dtp pointer!

(gdb) s
*_gfortran_st_write_done (dtp=0x7fffffffe640)
    at ../../../gcc4x/libgfortran/io/transfer.c:2546
2546      if (dtp->u.p.scratch != NULL)
(gdb) s
2548      if (dtp->u.p.current_unit != NULL)
(gdb) s
2549        unlock_unit (dtp->u.p.current_unit);
(gdb) s
*_gfortrani_unlock_unit (u=0x2008103b0) at gthr-posix.h:566
566       if (__gthread_active_p ())
(gdb) p dtp
No symbol "dtp" in current context.
(gdb) p u
$5 = (gfc_unit *) 0x2008103b0
(gdb) p *u
$6 = {unit_number = 10, s = 0x200828000, left = 0x0, right = 0x0,
  priority = 14047, read_bad = 1, current_record = 1, endfile = NO_ENDFILE,
  mode = WRITING, flags = {access = ACCESS_STREAM, action = ACTION_READWRITE,
    blank = BLANK_NULL, delim = DELIM_NONE, form = FORM_UNFORMATTED,
    is_notpadded = 0, position = POSITION_ASIS, status = STATUS_UNKNOWN,
    pad = PAD_YES, convert = CONVERT_NATIVE}, recl = 1, last_record = 25,
  maxrec = 9223372036854775807, bytes_left = 0, lock = 0x0, waiting = 0,
  closed = 0, ls = 0x0, rank = 0, file_len = 10,
  file = 0x20082c140 "teststream"}
(gdb) s
567         return __gthrw_(pthread_mutex_unlock) (mutex);
(gdb) s

Breakpoint 1, *_gfortran_st_write (dtp=0x7fffffffe7d0)
    at ../../../gcc4x/libgfortran/io/transfer.c:2506
2506    {


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-08-18 20:54 ` jvdelisle at gcc dot gnu dot org
@ 2006-08-19  3:29 ` jvdelisle at gcc dot gnu dot org
  2006-08-19 15:55 ` howarth at nitro dot med dot uc dot edu
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-19  3:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2006-08-19 03:29 -------
Here is a comparison of no optimization and with -O1.  Does this code look the
same on x86-64 that is not FreeBSD?

Code with no optimization: This does not work.

        call    _gfortran_st_write_done
        movq    $.LC0, -424(%rbp)
        movl    $8, -416(%rbp)
        movl    $10, -428(%rbp)
        movq    $1, -392(%rbp)
        movl    $512, -432(%rbp)
        leaq    -432(%rbp), %rdi
        call    _gfortran_st_write

Code with -O1: This works

        call    _gfortran_st_write_done
        movq    $.LC0, 8(%rsp)
        movl    $8, 16(%rsp)
        movl    $10, 4(%rsp)
        movq    $1, 40(%rsp)
        movl    $512, (%rsp)
        movq    %rsp, %rdi
        call    _gfortran_st_write


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-08-19  3:29 ` jvdelisle at gcc dot gnu dot org
@ 2006-08-19 15:55 ` howarth at nitro dot med dot uc dot edu
  2006-08-19 16:52 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2006-08-19 15:55 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 885 bytes --]



------- Comment #7 from howarth at nitro dot med dot uc dot edu  2006-08-19 15:55 -------
Jerry,
    On Fedora Core 5 x86_64 with the svn pull from  a few days back and last
stream patch
I get the follow diff between the code generated with -O0 and -O1...

        call    _gfortran_st_write_done
-       movq    $.LC0, -600(%rbp)
-       movl    $8, -592(%rbp)
-       movl    $10, -604(%rbp)
-       movq    $1, -568(%rbp)
-       movl    $512, -608(%rbp)
-       leaq    -608(%rbp), %rdi
+       movq    $.LC0, 8(%rsp)
+       movl    $8, 16(%rsp)
+       movl    $10, 4(%rsp)
+       movq    $1, 40(%rsp)
+       movl    $512, (%rsp)
+       movq    %rsp, %rdi
        call    _gfortran_st_write

In both cases the reduced test case runs fine.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-08-19 15:55 ` howarth at nitro dot med dot uc dot edu
@ 2006-08-19 16:52 ` jvdelisle at gcc dot gnu dot org
  2006-08-20  4:26 ` jvdelisle at gcc dot gnu dot org
  2006-09-15 13:35 ` jvdelisle at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-19 16:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jvdelisle at gcc dot gnu dot org  2006-08-19 16:52 -------
I think this confirms the problem is in __gthrw_(pthread_mutex_unlock) (mutex)
on FreeBSD.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-08-19 16:52 ` jvdelisle at gcc dot gnu dot org
@ 2006-08-20  4:26 ` jvdelisle at gcc dot gnu dot org
  2006-09-15 13:35 ` jvdelisle at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-08-20  4:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-20 04:25:42
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libfortran/28747] Empty write STREAM I/O file positioning problem
  2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-08-20  4:26 ` jvdelisle at gcc dot gnu dot org
@ 2006-09-15 13:35 ` jvdelisle at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2006-09-15 13:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jvdelisle at gcc dot gnu dot org  2006-09-15 13:35 -------
Fixed on 4.2, will not go to 4.1

*** This bug has been marked as a duplicate of 29053 ***


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28747


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-09-15 13:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-16  3:12 [Bug libfortran/28747] New: Empty write STREAM I/O file positioning problem jvdelisle at gcc dot gnu dot org
2006-08-18 16:08 ` [Bug libfortran/28747] " jvdelisle at gcc dot gnu dot org
2006-08-18 16:12 ` jvdelisle at gcc dot gnu dot org
2006-08-18 16:15 ` pinskia at gcc dot gnu dot org
2006-08-18 16:30 ` jvdelisle at gcc dot gnu dot org
2006-08-18 20:54 ` jvdelisle at gcc dot gnu dot org
2006-08-19  3:29 ` jvdelisle at gcc dot gnu dot org
2006-08-19 15:55 ` howarth at nitro dot med dot uc dot edu
2006-08-19 16:52 ` jvdelisle at gcc dot gnu dot org
2006-08-20  4:26 ` jvdelisle at gcc dot gnu dot org
2006-09-15 13:35 ` jvdelisle at gcc dot gnu dot 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).