- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
=================================
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
=================================
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page