How to solve - corruption of the heap in f90

How to solve - corruption of the heap in f90

Hello All,

My main.90 fortran file is not executing completly and it is breaking on following code.
which gives following output log. can somebody help me what can I do to solve the trouble.

call formatcomp(FuelDistrib,2,ndMassDscFL,ndMassFL,comp_flags,ZFW_ID,CS_ID)

VSS Output log:

'test_lib_dbg.exe': Loaded 'C:\Users\Ajain\My Documents\Visual Studio 2008\Projects\mg1g1_perfo\bin\win32\Visual Studio 2008\test_lib_dbg.exe', Symbols loaded.
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\ntdll.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\kernel32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\imagehlp.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\advapi32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\rpcrt4.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\secur32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\msvcrt.dll'
HEAP[test_lib_dbg.exe]: Heap block at 08AE2958 modified at 08AE2B2D past requested size of 1cd
Windows has triggered a breakpoint in test_lib_dbg.exe.

This may be due to a corruption of the heap, which indicates a bug in test_lib_dbg.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while test_lib_dbg.exe has focus.

The output window may have more diagnostic information.
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\user32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\gdi32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\imm32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\MSCTF.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\version.dll'
'test_lib_dbg.exe': Unloaded 'C:\WINNT\system32\version.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\MSCTFIME.IME'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\ole32.dll'
'test_lib_dbg.exe': Loaded 'C:\WINNT\system32\oleaut32.dll'

test_lib_dbg.exe has triggered a breakpoint
The program '[3684] test_lib_dbg.exe: Native' has exited with code 0 (0x0).

 

Note:

As it menioned above, I never pressed f12 instead I pressed only f5/f10/f11

Dos output window shows File read & return Code 0

7 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Zitat:

HEAP[test_lib_dbg.exe]: Heap block at 08AE2958 modified at 08AE2B2D past requested size of 1cd

The valid range of heap addresses is 08AE2958 to 08AE2B24; the address modified, 08AE2B2D, is not in this range. In Fortran terms, this may suggest that you have, say, a CHARACTER*1 array 'str' of length 461 and you attempted to access str(470).

You need to enable traceback and run again to obtain the source line(s) that caused this error to occur. The information you have given is simply insufficient to say more.

Dera mecej4,

Thanks a lot for the answer, very useful. I have written and attached more debugg information. kindly verify and provide answer, if anything else I need to give please let me know. Please find the attachment if below written details are not readable.

    main.f90
   -----------

call formatcomp(FuelDistrib,2,ndMassDscFL,ndMassFL,comp_flags,ZFW_ID,CS_ID)

   formatcomp.c
   ------------

void formatcomp(double matrix[][10], int *nrow, int *ncol, int * comp_flag, int * idbaseMat, int * idtargetMat)

{
 

}

Debugg Information In VSS:
 

                Name                 Value                                Type

  FuelDistrib      {...}                            REAL(8)

  ndMassDscFL      Undefined variable ndMassDscFL 

  ndMassFL      Undefined variable ndMassFL
 
  comp_flags      {...}                            INTEGER(4)

  comp_flags(1)       2                                    INTEGER(4)

  comp_flags(2)       3                                    INTEGER(4)

  ZFW_ID               Undefined variable ZFW_ID
 
  CS_ID               Undefined variable CS_ID 

  -------------------------------------------------------------------------------------

       FuelDistrib(1,1,1) 0.000000000000000D+000 REAL(8)
  FuelDistrib(2,1,1) 0.000000000000000D+000 REAL(8)
  FuelDistrib(3,1,1) 0.000000000000000D+000 REAL(8)
          
                ........................................................
                ........................................................

                ........................................................

                ........................................................

                FuelDistrib(6,10,2) -170.091339111328 REAL(8)
  FuelDistrib(7,10,2) 398.197937011719 REAL(8)
  FuelDistrib(8,10,2) 357.680664062500 REAL(8)
  FuelDistrib(9,10,2) 245.521957397461 REAL(8)
  FuelDistrib(10,10,2) 18.7959365844727 REAL(8)
 

                ........................................................

                ........................................................

                ........................................................
              

 

                FuelDistrib(33,10,2) 0.000000000000000D+000 REAL(8)
  FuelDistrib(34,10,2) 0.000000000000000D+000 REAL(8)
  FuelDistrib(35,10,2) 0.000000000000000D+000 REAL(8)
  FuelDistrib(36,10,2) 0.000000000000000D+000 REAL(8)

 

 

Thank u very much....

Anlagen: 

AnhangGröße
Herunterladen heap-error.txt2.16 KB

Your FORTRAN call statement has one more arg than the C function

call formatcomp(FuelDistrib{1}, 2{2}, ndMassDscFL{3}, ndMassFL{4}, comp_flags{5}, ZFW_ID{6}, CS_ID{7})

void formatcomp(double matrix[][10]{1}, int *nrow{2}, int *ncol{3}, int * comp_flag{4}, int * idbaseMat{5}, int * idtargetMat{6})

 Jim Dempsey

www.quickthreadprogramming.com

Dear Jimm,

""void formatcomp(double matrix[][10]{1}, int *nrow{2}, int *ncol{3}, int * comp_flag{4}, int * idbaseMat{5}, int * idtargetMat{6})"" !!!!!!!!!!!!!

Oops!!!!!!! I provided wrong arguments due to hurry. Below mentioned is the correct one, if you can... pls verify again. May be a different error?????

Correct One:

void  formatcomp(double * matrix{1}, int *nmat{2}, int *nrow{3}, int *ncol{4}, int * comp_flag{5}, int * idbaseMat{6}, int * idtargetMat{7})
                                           
                                              VS

call formatcomp(FuelDistrib{1}, 2{2}, ndMassDscFL{3}, ndMassFL{4}, comp_flags{5}, ZFW_ID{6}, CS_ID{7})

 

Thanks u very much for the answer, you said exactly correct according to what I provided in my prvious post.

 

double matrix[][10]  Two dimensions
FuelDistrib(7,10,2)  Three dimensions

I suggest you define the C matrix as single dimension, pass the reference of the first cell in FORTRAN, and pass size of each dimension.
Then use a conversion function in C to produce the index.

Jim Dempsey

www.quickthreadprogramming.com

Dear Jim,

Thank you very much for the answer. I am working on it

 

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen