View previous topic :: View next topic |
Author |
Message |
KennyT
Joined: 02 Aug 2005 Posts: 320
|
Posted: Tue Nov 22, 2011 5:09 pm Post subject: Stack overflow - relink program with bigger stack value |
|
|
OK, so I'm getting the above error and have tried to increase the stack to no avail. I've tracked the crash to a call which never gets to the subroutine - the crash occurs when I try to "step into" the subroutine under the debugger. The subroutine has two integer arrays as arguments, one dimensioned (0:3), the other (4).
The "calling stack" when it crashes looks OK, arguments seem to match all the way "down the tree".
I have tried:
1 removing the arrays from the call and subroutine lines, just in case it didn't like the (0:3)
2 moving the call to another part of the calling routine
3 moving the subroutine from its natural home source file to the same source file as the call, because I couldn't think of what else to do!
What else can I try?
TIA
K |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Wed Nov 23, 2011 9:08 am Post subject: |
|
|
First two thoughts:
1) Does it depend on using /checkmate etc.
2) What happens if you remove the call. i.e. has the problem already occured before this point in the code. |
|
Back to top |
|
 |
KennyT
Joined: 02 Aug 2005 Posts: 320
|
Posted: Wed Nov 23, 2011 9:57 am Post subject: |
|
|
Hi Paul,
I don''t use /checkmate, only /debug or /undef (or nothing) and the results are the same, either the crash message above when just running the app, or the equivalent (exception 0XC00000FD in "adjust stack") when under the debugger.
If I remove the call, execution continues normally (although the functionality normally provided by the subroutine means that the program won't progress much further!).
K |
|
Back to top |
|
 |
KennyT
Joined: 02 Aug 2005 Posts: 320
|
Posted: Wed Nov 23, 2011 11:00 am Post subject: |
|
|
OK, found it. In the subroutine I had a TYPE statement for an unused structure, CO:
TYPE (CONSL) :: CO
if I either comment it out or change it to:
TYPE (CONSL),POINTER :: CO
The crash does not occur!
What I don't understand is, if I'm not currently using "CO" in that subroutine, why does how it's defined make such a difference? What if I want to start using it soon (which his why the definition was in there in the first place!)?
K |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Wed Nov 23, 2011 11:04 am Post subject: |
|
|
The pointer only uses 4 bytes of memory whilst the other depends on the size of the structure. Maybe the structure is not defined correctly. |
|
Back to top |
|
 |
|