Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

0xC0000005 Access Violation Writing Location Error

emreka82
Beginner
27,757 Views

Hi,

I am writing a code with large arrays. The code works fine for small matrices but when I go beyond a certain level, the following error pops out:

Unhandled exception at 0x77913560 in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000050e14.

I am dynamically allocating memory with variables, then deallocating them. The code is very long, longer than 20,000 lines. I want to trace the problem. Before deciding to start this topic, I search the forum and other sources. The "Stack Size" problem has seemed reasonable. I changed reserve size to 200,000,000 and commit size 20,000,000. The problem stayed the same with small differences:

Unhandled exception at 0x77913560 in 3d.exe: 0xC0000005: Access violation writing location 0x00000000001e0e84.

As you can see the code given at the end of the error line is different, I want to know and trace the error. Any kind of help will be appreciated. Thanks !

Emre

0 Kudos
93 Replies
SergeyKostrov
Valued Contributor II
14,124 Views
Please try to use -heap-arrays 1024 ( or 2048, 4096, etc ) Fortran compiler option. Also, How much physical and virtual memory do you have on your system? How big are arrays and what are their data types? Thanks in advance.
0 Kudos
emreka82
Beginner
14,124 Views

Thanks for the quick answer Sergey. I changed heap arrays to 1024. Now, I'm running the code....The problem does not change, but the place of it:

Unhandled exception at 0x000007fef5e3fe67 in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000120ff8.

Physical Memory is 4GB and the virtual memory is set to min and max value of 2048 and 6000 MB . The maximum array size is 7 to 5 but the recursive subroutines and the pointers increase them. To make it clear: An 4x3 array with one-level high 1D array (which is pointed by 4x3 array) inside a recursive subroutine which calls 172 times itself and in the 173rd call the code breaks. The array elements are float, in Fortran literature real*8.

0 Kudos
SergeyKostrov
Valued Contributor II
14,124 Views
>>...Physical Memory is 4GB and the virtual memory is set to min and max value of 2048 and 6000MB.. Try to set the following combinations of Min and Max Virtual Memory values: [ Case 1 ] Min = 6GB Max = 12GB [ Case 2 ] Min = 8GB Max = 16GB [ Case 3 ] Min = 12GB Max = 24GB etc In overall you need to find a right set of values! If your codes do not have any hidden problems ( processing with smaller arrays works ) then your recursive processing is bound to Physical Memory up to some level and after that it is bound to Virtual Memory ( performance of processing will be affected ). There are No known to me limitations with Intel Fortran compiler and I recently allocated 128GB of memory for three 64Kx64K matricies in a test case.
0 Kudos
SergeyKostrov
Valued Contributor II
14,124 Views
Please take a look at: Forum Topic: A possible bug in the compiler - Forrtl: severe (41): insufficient virtual memory Web-link: software.intel.com/en-us/forums/topic/377056 I don't confirm a bug. A screenshot and test project attached.
0 Kudos
jimdempseyatthecove
Honored Contributor III
14,124 Views

My guess is you are writing to an uninitialized (garbage) reference or writing beyond or before an array. The location written to was  0x0000000000120ff8 which is deffinately not on your x64 stack. 0120ff8 == 1183736. Add code to assert anything about to be referenced is not below 1183744. (your code will have been in error well before this, but this should be a good assert condition)

recursive subrouting FOO(A)
real :: A(4,3)
CALL CHECKLOC(LOC(A))
...
CALL CHECKLOC(LOC(A(I,J))
X =A(I,J)
...

SUBROUTINE CHECKLOC(L)
INTEGER(8) :: L

IF(L  .le. 1183744) THEN
WRITE(*,*) "BUG - PLACE BREAK HERE"
ENDIF
END SUBROUTING CHECKLOC

jIm Dempsey

0 Kudos
emreka82
Beginner
14,124 Views

Hi Jim,

I apply your suggestion in my code, but it is hard to find the problem. When I insert the "call FOO" statements in my code, the program gives the same error with another location:

Unhandled exception at 0x000007feff7ffaad in 3d.exe: 0xC0000005: Access violation writing location 0x00000000000a0fe8.

Actually, I give the 4x3 array as an example. I do not know the "exact" problematic array. There are 20+ different arrays in my code.

0 Kudos
emreka82
Beginner
14,124 Views

@ Sergey,

I use min 11GB max 22GB but the error stays the same. By the way, when I remove a "one line self-calling(recursive)" do-loop inside the problematic subroutine, the error disappears but ,as expected, my code gives wrong outputs.

0 Kudos
Steven_L_Intel1
Employee
14,124 Views

Access violation is not usually related to size of memory used. If you run the program under the debugger, it should stop at the point of the error (sometimes you may need to look at earlier stack frames to see your code rather than library code). If you enable traceback, it will tell you where the error occurred. I suggest using Intel Inspector XE's memory analysis to see if it identifies allocatable memory usage errors.

0 Kudos
emreka82
Beginner
14,124 Views

Steve Lionel (Intel) wrote:

Access violation is not usually related to size of memory used. If you run the program under the debugger, it should stop at the point of the error (sometimes you may need to look at earlier stack frames to see your code rather than library code). If you enable traceback, it will tell you where the error occurred. I suggest using Intel Inspector XE's memory analysis to see if it identifies allocatable memory usage errors.

Yes, I increase the virtual memory even more ( 21GB-42GB) but the stopping point is the same, (the error point) is the starting line of one of my recursive subroutine.

I don't know how to enable traceback, would you tell me how?...I did not hear before the functionality of Intel Inspector in this type of problems. I will try that. Thanks Steve !  

0 Kudos
Steven_L_Intel1
Employee
14,124 Views

You enable traceback by adding /traceback on the command line. It is the default when building a debug configuration.

0 Kudos
SergeyKostrov
Valued Contributor II
14,124 Views
>>...I increase the virtual memory even more ( 21GB-42GB) but the stopping point is the same, (the error point) is >>the starting line of one of my recursive subroutine... Could you provide some details on what the code does in the recursive subroutine?
0 Kudos
Bernard
Valued Contributor I
14,124 Views
>>>Unhandled exception at 0x000007fef5e3fe67 in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000120ff8.>>> This exception can be due to some wrong pointer passed in registers or some garbage loaded in register and dereferenced by the code. !address 0x00000000000120ff8 should reveal the what is the memory content in this address.
0 Kudos
emreka82
Beginner
14,124 Views

Sergey Kostrov wrote:

>>...I increase the virtual memory even more ( 21GB-42GB) but the stopping point is the same, (the error point) is
>>the starting line of one of my recursive subroutine...

Could you provide some details on what the code does in the recursive subroutine?

The recursive subroutine is a 300 line subroutine which is constructed for a 3 dimensional grid generator, works as a cut-cell refiner. It calls itself at 8 different parts of it and also some of them are in a do loop. It also calls 10 different subroutines. 

0 Kudos
emreka82
Beginner
14,124 Views

iliyapolak wrote:

>>>Unhandled exception at 0x000007fef5e3fe67 in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000120ff8.>>>

This exception can be due to some wrong pointer passed in registers or some garbage loaded in register and dereferenced by the code.
!address 0x00000000000120ff8 should reveal the what is the memory content in this address.

I guess so, the thing is I cannot find the wrong pointer.Can you tell me or show me how can I change this adresses into location to find this uninitialized (garbage) reference ? ( as jim dempsey said before  0120ff8 == 1183736. but when I change the virtual memory limits, it changes too. Thanks.

0 Kudos
emreka82
Beginner
14,124 Views

Steve Lionel (Intel) wrote:

You enable traceback by adding /traceback on the command line. It is the default when building a debug configuration.

Ok, Steve. /traceback is in the command line by default. I will try Inspector on Monday, then I will share the results.

0 Kudos
emreka82
Beginner
14,123 Views

Let me show the problem page and the outputs, maybe it can show you that I cannot see. I upload the screenshots of the error and the "call stack" outputs (as part1 and part2) after the break.

0 Kudos
emreka82
Beginner
14,123 Views

I forgot it. When I stop the debugger after this access violation error, the debug output gives:

'3d.exe': Loaded 'E:\3d\x64\Debug\3d.exe', Symbols loaded.
'3d.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\imagehlp.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'3d.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
First-chance exception at 0x0000000140617977 in 3d.exe: 0xC00000FD: Stack overflow.
'3d.exe': Loaded 'C:\Windows\System32\dbghelp.dll', Cannot find or open the PDB file
First-chance exception at 0x000007feff57faad in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000040fa8.
Unhandled exception at 0x000007feff57faad in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000040fa8.
First-chance exception at 0x000007feff57faad in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000040fa8.
Unhandled exception at 0x000007feff57faad in 3d.exe: 0xC0000005: Access violation writing location 0x0000000000040fa8.
The program '[6524] 3d.exe: Native' has exited with code -1073741819 (0xc0000005).

0 Kudos
jimdempseyatthecove
Honored Contributor III
14,123 Views

>>First-chance exception at 0x0000000140617977 in 3d.exe: 0xC00000FD: Stack overflow.

0 Kudos
emreka82
Beginner
14,123 Views

jimdempseyatthecove wrote:

>>First-chance exception at 0x0000000140617977 in 3d.exe: 0xC00000FD: Stack overflow.

I found a thread which is very similar to mine:

http://software.intel.com/en-us/forums/topic/282409

0 Kudos
Bernard
Valued Contributor I
10,278 Views
>>>Can you tell me or show me how can I change this adresses into location to find this uninitialized (garbage) reference ?>>> You need to run your program under windbg and issue the !address command on the suspected address.I bet that you are trying to execute or to read from so called PAGE_NOACCESS memory.
0 Kudos
Reply