Silverfrost Forums

Welcome to our forums

JIT Compiler encountered an internal limitation

29 Mar 2016 11:24 #17361

Hello, I face this problem with FTN95 Express today.

The Express solution platform is in .NET mode. But when I get into debug mode, at a point calling for a subroutine, it was showing this error as given below (unable to paste the screenshot here)

InvalidProgramException occured JIT compiler encountered an internal limitation

System.InvalidProgramException occurred Message: JIT Compiler encountered an internal limitation

So, I am unable to catch/ trace the bug in FTN95 Express IDE. My laptop has a 64bit processor.

But if I change the solution platform to Win32, it debugs and goes through nicely without any error or exceptions. Is this due to a conflict of 32bit Compiler on 64bit hardware. Any idea?

I thought of approaching our Support Forum to seek for the suitable solutions to make this to run in .NET or what should be done next. Pls. suggest.

5 Apr 2016 4:02 #17381

Thats a good suggestion John. Thanks.

But please let me know what is the issue. Even now, I am facing this problem.

When I go for Release .NET, Release Win32, Debug .NET the exe file is built, but gives the run time error of what I quoted earlier. But when I build in Debug win32, Checkmate Win32 platform, it runs absolutely fine. In short, I am unable to make the Release executables as of now.

But I don't think it is of any code related issues, but with OS Bits related. I use Win7 64 bit i7 processor. If that is so, what parameters to be set while compiling and building to overcome this issue. Pls. suggest.

5 Apr 2016 4:35 #17382

Hi John I just want to share more details, to give better understanding of the problems that I faced.

As said before, I show the error I faced in each build mode.

Debug .NET D:\C00\C02\SparseDll\TestSparse\Debug\NET>TestSparse.exe Please enter the input file:D:\C00\C02\Sparse\TestIn1b.dat Please enter the Output file:D:\C00\C02\Sparse\SymmSparse\aa 10 Calling StoreMatrix Routine..

Unhandled Exception: System.InvalidProgramException: JIT Compiler encountered an internal limitation. at TestSparse.STORESYMMATRIX() at TestSparse.SPARSE() in D:\C00\C02\SparseDll\BiFact_01.F95:line 554


Release .NET

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at TestSparse.SIMLORDERSYMMATRIX() at TestSparse.SPARSE() in D:\C00\C02\SparseDll\BiFact_01.F95:line 299


Release Win32

Runtime error from program:d:\c00\c02\sparsedll\testsparse\release\win32\testsparse.exe Access Violation The instruction at address 004053af attempted to read from location 113ea9f0

00404760 STORESYMMATRIX [+0c4f]

00401960 SPARSE [+1002]

eax=0360f4f0 ebx=0360f654 ecx=00000045 edx=0008e3c8 esi=0040811c edi=03776d40 ebp=0360f888 esp=0360f4ec IOPL=2 ds=002b es=002b fs=0053 gs=002b cs=0023 ss=002b flgs=00010202 [NC OP NZ SN DN NV]

004053af mov ecx,[eax+edi*4] 004053b3 mov esi,[ebp-0x248] 004053b9 mov [esi],ecx

I only see that Debug Win32 and Checkmate Win32 platform builds are absolutely fine working in runtime. The rest are showing the running time problem as above.

My Laptop is with Intel Core(TM) i7 processor, with Win7 64bit OS.

I am able to suspect, that the Compiled build does not support 64bits in Release Mode (.NET/Win32). But in that case, how the Debug Win32 are working fine.

What is the root cause of my problem. Can I overcome this with some switches while building. I have even tried with dbk_link4 for linking the dbk files in .NET platform.

Any suggestions, clues to overcome this issues. Thanks in advance..

7 Apr 2016 1:50 #17383

Quoted from narayanamoorthy_k

But I don't think it is of any code related issues, but with OS Bits related. If that is so, what parameters to be set while compiling and building to overcome this issue. Pls. suggest.

I suspect that you are not only barking up the wrong tree but also doing so rather perversely.

You have not shown us the source code that is giving you errors, not even a fragment. If you think that there are some magical compiler options that will diagnose and fix the problem no matter what the source code is, you are mistaken.

FTN95/Win32 provides excellent debugging facilities, many of which are unavailable when you use FTN95/NET.

The error traceback that you showed in your post (of Mon Apr 04, 2016 10:35 pm) gives a clear indication to me that the problem is being caused by trying to do read-access on an array variable with an incorrect index. Specifically, I suspect that EDI would contain the index value, and EAX contains the address of the base of the array, each element of which occupies 4 bytes. In this case, you have something such as A(I), with I = Z'03776d40' = 58158400. Is it reasonable to have an index with a value of over 58 million?

I suggest that you recompile with /check and locate the line number in the source code where the subscript error occurs. If using /check makes the bug stay hidden, things are a bit tougher, but there are other methods that can be used -- a bridge to be crossed later, if necessary.

7 Apr 2016 6:09 (Edited: 10 Apr 2016 6:51) #17384

Thanks mecej4 and John.. I am still debugging that issue.

Perhaps, it just occurs that .NET was picking wrongly in my laptop. But I have already installed .NET Framework 4.5.1 and 4.6 SDK. Earlier, I just uninstalled the FTN95 Express and Reinstalled, but I have not invoked the FTN95 from FTN95 Express installer, as I have the FTN95 personal edition already active and the Express use that FTN95 personal edition kernal. This combination is excellent as it helps a lot in 'Step-into (F11)' steps as it shows the values of arrays and others very clearly.

Coming back to my code which just calls another subroutine only. Pls. see the code below.

 551       print*, 'Calling StoreMatrix Routine..'
 552       !iArrayRowSize=ToT
             !iArrayColSize=ToT
 554       call StoreSymMatrix
             if (.not. StoreMatrix ) then
               print*, 'Error: Problem in StoreSymMatrix..Exiting..'
               goto 900
 558       endif

But the StoreSymMatrix Routine is given below.

7 Apr 2016 6:13 (Edited: 11 Apr 2016 4:20) #17385

Thanks mecej4 and John.. I am still debugging that issue.

Perhaps, it just occurs that .NET was picking wrongly in my laptop. But I have already installed .NET Framework 4.5.1 and 4.6 SDK. Earlier, I just uninstalled the FTN95 Express and Reinstalled, but I have not invoked the FTN95 from FTN95 Express installer, as I have the FTN95 personal edition already active and the Express use that FTN95 personal edition kernal. This combination is excellent as it helps a lot in 'Step-into (F11)' steps as it shows the values of arrays and others very clearly.

Coming back to my code which just calls another subroutine only. Pls. see the code below.

 551       print*, 'Calling StoreMatrix Routine..'
 552       !iArrayRowSize=ToT
             !iArrayColSize=ToT
 554       call StoreSymMatrix
             if (.not. StoreMatrix ) then
               print*, 'Error: Problem in StoreSymMatrix..Exiting..'
               goto 900
 558       endif

But the StoreSymMatrix Routine is given below.

7 Apr 2016 6:15 #17386

Sorry, my full reply does not show here in one post, hence splitting it .

Part 1:

Thanks mecej4 and John.. I am still debugging that issue.

Perhaps, it just occurs that .NET was picking wrongly in my laptop. But I have already installed .NET Framework 4.5.1 and 4.6 SDK. Earlier, I just uninstalled the FTN95 Express and Reinstalled, but I have not invoked the FTN95 from FTN95 Express installer, as I have the FTN95 personal edition already active and the Express use that FTN95 personal edition kernal. This combination is excellent as it helps a lot in 'Step-into (F11)' steps as it shows the values of arrays and others very clearly.

Coming back to my code which just calls another subroutine only. Pls. see the code below.

 551       print*, 'Calling StoreMatrix Routine..'
 552       !iArrayRowSize=ToT
             !iArrayColSize=ToT
 554       call StoreSymMatrix
             if (.not. StoreMatrix ) then
               print*, 'Error: Problem in StoreSymMatrix..Exiting..'
               goto 900
 558       endif
7 Apr 2016 6:17 (Edited: 10 Apr 2016 6:54) #17387

THanks John I tried to delete this post. but There is edit/delete option of the individual post. When I clicked, it showed me Edit Post window, and I deleted the message window. But I am unable to see the 'Delete Post' option in the respective message post. How do I do it. Thanks

7 Apr 2016 6:19 #17388

I see that the subroutine doesn't post completely. WIll send it through PM

The rest part of my reply Part 3:

But here in StoreSymMatrix subroutine just stores a given array. It works fine with Win32 compilation, but not with .NET.

I am reproducing the code as mecej4 and you also liked to view it.

Anyhow, thanks for your attention to help me out. Even while I am talking now, I just uninstalled FTN95 Express and am going to reinstall again to check. Perhaps, the .NET version also I have to check and install if any latest one. However, I have noticed that FTN95 Express installs the 'visual studio shell 2008 (isolated)' and later I just installed the latest shell 2013 (isolated) also, assuming that might help. But no success so far.

I keep pushing myself for this visual studio type of debugging, as I love it as it provides so many facilities to view the interim values of each line of codes and loops, which are very good for not to write so many print statements to view the code to understand how it behaves.. Thats why. Hope you also liked this. I see that PLATO does not provide that values to be shown dynamically for every lines of code. Thats only disadvantage I see with PLATO.

Thank a lot mecej4 and John.

7 Apr 2016 7:03 (Edited: 8 Apr 2016 12:23) #17389

I'm afraid that your code fragments add up to more lines of code than I am inclined to read line by line.

Not much can be done until you post the source codes for all the subroutines, modules and the main program plus any needed data files, and provide instructions for building and running the program in such a way that the bug can be reproduced.

The Silverfrost forum does not allow posting large amounts of code. Please zip up all the files that you need, upload the zip file to a shareable cloud storage space such as OneDrive, DropBox, Google Drive, etc., and provide a link in a post to this forum.

8 Apr 2016 2:12 #17390

I may be wrong, but I have never considered that .NET is a useful coding environment for linear equation solution, while win32 and soon FTN95 /64 to be more suited. Win32 and .NET are very different.

Is finding the problem with this .NET approach more related to an unsuitable environment, rather than a code problem ?

8 Apr 2016 4:37 #17391

Quoted from JohnCampbell I may be wrong, but I have never considered that .NET is a useful coding environment for linear equation solution, while win32 and soon FTN95 /64 to be more suited. Win32 and .NET are very different.

Is finding the problem with this .NET approach more related to an unsuitable environment, rather than a code problem ?

I think that the meanderings in this thread have spread more confusion than necessary. If I am not mistaken, OP is working with a character mode Fortran program. When he mentions '.NET', he is talking about using FTN95 to compile the Fortran source code into MSIL, which is then run on the .NET VM. In other cases, he has FTN95 compiling and linking the code to generate a Win32 PE EXE. Therefore, as far as 'coding environment' is concerned, there is only one: Fortran source code using some editor (Plato, VS Editor, ...) .

When there are bugs in the Fortran source code, the (mis)behavior of the compiled program is, in general, ill-defined and, as we may expect, depend on the 'instruction set' that is targeted (X86 instruction set or MSIL).

10 Apr 2016 6:57 #17395

Quoted from mecej4 I'm afraid that your code fragments add up to more lines of code than I am inclined to read line by line.

Not much can be done until you post the source codes for all the subroutines, modules and the main program plus any needed data files, and provide instructions for building and running the program in such a way that the bug can be reproduced.

The Silverfrost forum does not allow posting large amounts of code. Please zip up all the files that you need, upload the zip file to a shareable cloud storage space such as OneDrive, DropBox, Google Drive, etc., and provide a link in a post to this forum.

Thanks mecej4. I realised this while posting my message. but before 'submit'ting the post, while seeing the 'Preview', it shows me the complete post preview, hence Am submitted that post.

I will follow the code sending like the way you suggested. Thanks a lot.

10 Apr 2016 7:01 #17396

Quoted from narayanamoorthy_k

Thanks mecej4. I realised this while posting my message. but before 'submit'ting the post, while seeing the 'Preview', it shows me the complete post preview, hence Am submitted that post.

I will follow the code sending like the way you suggested. Thanks a lot.

Hi mecej4. Just after posting the previous message, I see that my post shows the 'x' button on its right top corner. Means, I am now only started getting that feature in my posting. Earlier I never seen it. But I don't get that in the older posts.

Thanks.

10 Apr 2016 7:07 #17397

Quoted from John-Silver

I have the FTN95 personal edition already active and the Express use that FTN95 personal edition kernal

I don't understand. The Express version is 'sealed' as far as I'm aware and uses v5.4 (very old now) of the compiler. As far as I'm aware its not possivle to 'activate' the latest compiler version from within Express. hence my suggestion of community version of VS + Personal version compiler

I mean the FTN95 express (visual studio IDE) V5.4 from this link where I downloaded.

http://www.silverfrost.com/52/ftn95_express.aspx

Is it frozen one and not active?

11 Apr 2016 5:04 #17398

Quoted from narayanamoorthy_k

Quoted from mecej4 I'm afraid that your code fragments add up to more lines of code than I am inclined to read line by line.

Not much can be done until you post the source codes for all the subroutines, modules and the main program plus any needed data files, and provide instructions for building and running the program in such a way that the bug can be reproduced.

The Silverfrost forum does not allow posting large amounts of code. Please zip up all the files that you need, upload the zip file to a shareable cloud storage space such as OneDrive, DropBox, Google Drive, etc., and provide a link in a post to this forum.

Thanks mecej4. I realised this while posting my message. but before 'submit'ting the post, while seeing the 'Preview', it shows me the complete post preview, hence Am submitted that post.

I will follow the code sending like the way you suggested. Thanks a lot.

Hi John, mecej4

Greetings.

I have uploaded my code in rar file in the Google Drive. Pls. find the link below.

https://drive.google.com/file/d/0B0mTpY0HUClYNmE5bFF0X2pXYjQ/view?usp=docslist_api

It consists the following: Fortran files: BiFact_01.f95 = Main file Remaining f95 = associated fortran files TestIn1a.dat = Input data file.

Just simply build it using our FTN95 and the JIT issues can be seen in .NET building the solution or this project.

Pls. let me know, if you see any issues why it is not successfully running during Runtime, when it has been built in .NET environment.

Thanks a lot in advance and for your attention.

12 Apr 2016 2:18 #17404

Moorthy,

I have no experience with .net so am not able to advise on it's use. My understanding of .net is that it is not suited to solution to large sets of equations, although the example size you have supplied is not large.

I did look at the code you supplied. It is not a style of code that I would use, as you have extensive use of GOTO and statement numbers. Fortran 90 provides for CYCLE and EXIT in DO loops and IF () THEN ; ELSE constructs, which can assist with the flow of the code. However, if you prefer the use of GOTO and statement numbers, this code will still work, if the logic is correct. I changed SUBROUTINE DIRECTSOLUTIONSYMMATRIX to use some of these features (hopefully correctly) to give you an idea of a different coding approach. Others probably have different ideas that are also valid. This should not be the source of your .net problem.

     SUBROUTINE DIRECTSOLUTIONSYMMATRIX

     	USE globalmaster      !  Inputs : NORDR, NSEQ(*), LCOL(*), LNXT(*), ITAG(*), V(*), CE(*)

	    INTEGER :: L, i,j,k   ! variables not used KP, LK, IP, LN, LA, MIN, M, 
	    real :: CF, SUM

!    The following are not required
!	    KP=0
!	    LK=0
!	    IP=0
!	    LN=0
!	    LA=0
!	    MIN=0
!	    M=0
!
!	    L=0
!	    CF=0.
!	    SUM=0.
	    
        DO J = 1,NORDER
          K    = NSEQ(J)
          CF   = V(K)
          V(K) = 0
          L    = LCOL(K)
          DO WHILE (L > 0)
            I    = ITAG(L)
            V(I) = V(I) + CE(L)*CF
            L    = LNXT(L)
          END DO
        END DO		

        DO J = (NORDER-1),1,-1
          K   = NSEQ(J)
          SUM = V(K)
          L   = LCOL(K)
          DO WHILE (L > 0)
            I = ITAG(L)
            IF ( I /= K ) SUM = SUM + CE(L)*V(I)
            L = LNXT(L)
          END DO
          V(K) = SUM
         END DO
         DirectSolution = .true.

	  print*, 'Direction Solution just completed.....'
!!!
!!!      print*, 'No.              LCOL          NOZE          NSEQ'
!!!      DO II = 1, (YMAT1SIZE) !IARRAYCOLSIZE
!!!        WRITE(*,222) II,LCOL(II), NOZE(II),NSEQ(II)
!!!      END DO
!!! 
!!!      PRINT*, 'YMAT2 MATRIX' 
!!!      PRINT*, 'II,     ITAG,       LNXT,          CE'	  
!!!      DO II = 1, (YMAT2SIZE)
!!!        WRITE(*,223) II, ITAG(II), LNXT(II),CE(II)
!!!      END DO
!!!
!!! 222  FORMAT(I2,'   ',I3,'     ',I3,'     ', I3)     
!!! 223  FORMAT(I2,'     ',I3,'     ',I3,'       ',F8.2)
!!!  

     END SUBROUTINE DIRECTSOLUTIONSYMMATRIX
12 Apr 2016 2:21 #17405

As I suspected, the program has bugs and is rather cluttered :

o Pointer variables are used with ALLOCATED o The output file is opened with STATUS='OLD' o Unit numbers 5 and 6 are used to open disk files o Lots of lines of code that have been commented out o Many variables are declared (and assigned values) unnecessarily.

I have cleaned up the code and placed it at

https://www.dropbox.com/s/g07ljzp2t2c9tzt/symmat.rar?dl=0

The cleaned up code can be compiled and linked either for Win32 or .NET. It runs to completion and outputs results that appear reasonable (but you must check if the results are, in fact, correct).

While cleaning up the code and attempting to run it, I found that FTN95 sometimes outputs buggy code when expressions containing UBOUND are used as indices (and, perhaps, in the loop control list of a DO construct. I have reported this bug separately ( https://forums.silverfrost.com/Forum/Topic/2862 ) . To side-step this bug, use a local variable, assign the UBOUND value to the local variable and use the local variable in subscript expressions and DO loop control lists.

12 Apr 2016 4:05 #17406

Quoted from JohnCampbell Moorthy,

I have no experience with .net so am not able to advise on it's use. My understanding of .net is that it is not suited to solution to large sets of equations, although the example size you have supplied is not large.

I did look at the code you supplied. It is not a style of code that I would use, as you have extensive use of GOTO and statement numbers. Fortran 90 provides for CYCLE and EXIT in DO loops and IF () THEN ; ELSE constructs, which can assist with the flow of the code. However, if you prefer the use of GOTO and statement numbers, this code will still work, if the logic is correct. I changed SUBROUTINE DIRECTSOLUTIONSYMMATRIX to use some of these features (hopefully correctly) to give you an idea of a different coding approach. Others probably have different ideas that are also valid.

John Thank you very much for your time in taking my code and suggested the improved way of coding. Thanks a lot, Your ideas are very useful. In fact, I learn out of your suggestions as well.

I was focussing the logic to make it work correctly. But,I am new to FTN95 advanced features that uses fortran 90 specs. However, I will improve the code further too.

Thanks a lot and I will continue to remodel my code. Thank you

12 Apr 2016 4:30 #17407

Quoted from mecej4 As I suspected, the program has bugs and is rather cluttered :

o Pointer variables are used with ALLOCATED o The output file is opened with STATUS='OLD' o Unit numbers 5 and 6 are used to open disk files o Lots of lines of code that have been commented out o Many variables are declared (and assigned values) unnecessarily.

I have cleaned up the code and placed it at

https://www.dropbox.com/s/g07ljzp2t2c9tzt/symmat.rar?dl=0

The cleaned up code can be compiled and linked either for Win32 or .NET. It runs to completion and outputs results that appear reasonable (but you must check if the results are, in fact, correct).

While cleaning up the code and attempting to run it, I found that FTN95 sometimes outputs buggy code when expressions containing UBOUND are used as indices (and, perhaps, in the loop control list of a DO construct. I have reported this bug separately ( https://forums.silverfrost.com/Forum/Topic/2862 ) . To side-step this bug, use a local variable, assign the UBOUND value to the local variable and use the local variable in subscript expressions and DO loop control lists.

Dear mecej4

Thank you very much for your time in cleaning up my code to help me out to run them cleanly in win32 and .NET. Thanks a lot.

I will go through the code again and verify its working.

Its true that I also found the strange behaviour of UBOUND and added to that, the arrays keep the junk value which is observed in single-step debug mode, but while printing it prints the values correctly. Anyhow, I am happy that my code has helped to bring out one bug that can be fixed and improves our FTN95 compiler.

Once again, thanks a lot for your time and Ideas.. Its nice learning experience also to me to improve my code.

Thank you and John and to our forum to help me out to improve the way of the usage of FTN95. Fantastic and Amazing. A Big salute to you all and to our Forum.. Thanks a lot..

Please login to reply.