forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Code Generation Bug
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
mecej4



Joined: 31 Oct 2006
Posts: 976

PostPosted: Sat Sep 29, 2018 6:39 pm    Post subject: Code generation bug, 32 and 64 bit, unaffected by options Reply with quote

Paul's comments are quite sensible, and until now I had not succeeded in making the register usage bug to come alive in any 64-bit code. More poking around shows that all versions of FTN95 (I tried 6.35, 7.2, which are 32-bit only; 8.1, 8.2 and 8.3, 32-bit and 64-bit) are probably afflicted by this bug. Here is a reliable and surprisingly short reproducer.
Code:
program salREGbug
implicit none
integer, parameter :: double = kind(0.d0)
integer :: l = 2, jbl(2) = (/ 1, 2 /)
real(double) :: alf    = -3.86D-01
real(double) :: x(2)   = (/ 1.61D-2, -2.69D0 /)
real(double) :: abl(3) = (/ 7.75D2, 3.93D2, 2.01D2 /)
!
call sub(l, abl, jbl, alf, x)
write(*,'(A,2x,2ES12.4)')'X = ',x
stop
end program

subroutine sub(l, abl, jbl, alf, x)
   implicit none
   integer, parameter           :: double = kind(0.d0)
   integer , intent(in)         :: l, jbl(l)
   real(double) , intent(in)    :: alf, x(*)
   real(double) , intent(in out) :: abl(l*(l+1)/2)
   integer                      :: i, k
!
! FTN95 8.3 (32 and 64 bit) have errors in tracking usage of registers
!       in the code generated from the source lines below.
!
!       One or more registers may be overwritten with the values of
!       more than one variable and the register contents are
!       accessed later. Variable values, including the patterns used to
!       initialise variables when /undef is used, may end up being used
!       as base addresses of arrays.
!
   k = 0
   do i = 1, l
      if (jbl(i) <= 0)cycle
      where ( jbl(:i) > 0 ) &
         abl(k+1:i+k) = abl(k+1:i+k) + alf*x(jbl(i))*x(jbl(:i))
      k = i + k
   end do
end subroutine

I ran the versions of FTN95 that I listed using a number of options.

/checkmate
/check
-no option-
/opt
/opt /p6
/opt /64
/64
/64 /check
/64 /checkmate

The code aborted after an access violation in every one of the 37 runs. Note the improbable memory addresses from which a read is attempted at the point of the crash: with FTN95-8.30, the 32-bit program attempts to read from 0x20202020, and the 64-bit program attempts to read from 0x00000000.

The program has no errors; when run with, say, Gfortran, it gives:
Code:
X =     1.6100E-02 -2.6900E+00


Last edited by mecej4 on Sun Sep 30, 2018 1:02 am; edited 2 times in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5496
Location: Salford, UK

PostPosted: Sat Sep 29, 2018 8:37 pm    Post subject: Reply with quote

Many thanks for your effort and patience. We will investigate the issue.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group