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

memory bug?

David2
Beginner
373 Views

=================================
Warning! Attached code will crash computer!
=================================

The code I have included clearly has programmer errors, however what seem like simple programmer errors cause my machine to crash. Is this behavior correctable at the compiler level?

Have a look, and try the code. If compiled as is it will use all the memory in your machine and crash it, but you should have time to kill the process, have a extra window open and make sure to use

kill -s 9 PID



Clearly the problem is a programmer error, everyone should be using implicit none by now! Since the variable is implicitly declared and there is no interface checking, (there can not be interface checking) it is not a compile error as the code is written- however it seems to me that it might be possible to prevent the memory overflow at run time?


Any thoughts?

David
0 Kudos
6 Replies
David2
Beginner
373 Views


=================================
Warning! Attached code will crash computer!
=================================

Another insidious example!

Even with explicitly declared variables, passing the wrong dimension causes the same memory overflow. (is overflow the correct term?)

Again, the problem is a programmer error, but I was hoping intel might be able to make up for my own stupidity- or atleast prevent me from crashing the computer!

David
0 Kudos
TimP
Honored Contributor III
373 Views
Fortran provides MODULE and INTERFACE facilities to build in automatic checking for such errors. If you don't use those facilities, you should tryifort -check options. This would invoke both compile and run-time checks.
0 Kudos
David2
Beginner
373 Views


Hi Tim

I just tried:
ifort -check test2.f90 -o test2

I get no compile errors and no runtime errors, just the memory overflow.

I realize this is a programmer error which can be corrected by adding an explicit interface but since the consequences are severe I was hoping something might be do to help the unwitting since interfaces are not required (and should not be either).

My goal here is not to make up for the worlds sloppy programmers but to prevent them from causing havoc for the rest of us.

David
0 Kudos
TimP
Honored Contributor III
373 Views

I think you must specify -check all or give individual options, such as

-check uninit,bounds

In our experience, -check uninit errs on the side of giving too many warnings, rather than too few.

0 Kudos
David2
Beginner
373 Views


I still can't get:

ifort -check all test2.f90 -o test

to return an error


Is it unreasonable to expect such a programmer error to cause only that process to crash? What would be required to change in the compiler?
0 Kudos
Steven_L_Intel1
Employee
373 Views

The options "-gen-interface -warn interface" will give the compiler the additional information it needs to diagnose a programming error of this nature. For example (I did this on Windows):

F:MyProjects>ifort /gen-interface /warn:interface test2.f90
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20070322
Z Package ID: W_FC_C_9.1.037
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

test2.f90(10) : Error: If the actual argument is scalar, the corresponding dummy
argument shall be scalar unless the actual argument is an element of an array
that is not an assumed-shape or pointer array, or a substring of such an element.
[LSM]
call readnc(lsm)
---------^
compilation aborted for test2.f90 (code 1)

I see nothing in this program that would crash the computer. I would expect that this program would corrupt the user memory stack, and that could cause a run-time error. If the OScrashes because of that, that's an OS bug.

0 Kudos
Reply