Fortran Debug Bus Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn segmentation fault gfortran more about Stack Overflow the company Business Learn more about hiring developers or fortran segmentation fault (core dumped) posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow gfortran traceback Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Fortran Bus Error When Modifying Parameter up vote 0 program received signal sigsegv: segmentation fault - invalid memory reference. down vote favorite Whenever I assign a new value to a parameter, I get a bus error. I don't see how I'm pointing to non-existant memory. I should have access to this address, as it is declared in the parameter list, unless Fortran does not allow parameters to be modified without some special declaration. The rest of my code works without error. I've isolated it to simply this
Gfortran Compiler Options
assignment. I'm running gfortran (not sure which version, off-hand) from the terminal in OS X. SUBROUTINE p_list (c_number, c_matrix) INTEGER c_number INTEGER c_matrix(8000,20) ! ... c_number = 1000 ! ... END SUBROUTINE p_list parameters fortran bus-error share|improve this question asked Dec 13 '10 at 12:12 Old McStopher 3,69174777 3 How are you calling this? I don't know modern FORTRANs, but I know that with earlier versions of FORTRAN, you could crash a program like that by passing in a constant (e.g., by calling p_list(0, my_matrix)). That's because FORTRAN implicitly passed everything by reference, including constants (!) –Dan Breslau Dec 13 '10 at 12:19 Actually, great catch. The call from main was a test line of code using a constant. Replacing it with a declared INTEGER in the call, seemed to do the trick! Promote this comment to an answer, and I'll select it as the winner. ;) –Old McStopher Dec 13 '10 at 12:24 I'm not sure if I want to "win" a FORTRAN question, but OK ;-) –Dan Breslau Dec 13 '10 at 12:30 1 @Old McStopher: I suggest you declare INTENTs on arguments to subroutines; you'll get a lot more help from th
LearningModern CodeNetworkingOpen SourceStorageToolsDeveloper TypeEmbedded SystemsGame DevMediaTechnical, Enterprise, HPCWebOSAll ToolsAndroid*HTML5Linux*OS X*Windows*ResourcesCode SamplesContact SupportDocumentationFree SoftwareIntel Registration CenterProduct ForumsSDKsResourcesPartner with IntelAcademic ProgramPartner SpotlightBlack Belt DeveloperDeveloper MeshInnovator ProgramSuccess StoriesLearnBlogBusiness TipsEventsVideosSupportContact
Ifort
SupportDeveloper EvangelistsFAQsForums Search form Search Determining Root Cause of Segmentation how to use gdb Faults SIGSEGV or SIGBUS errors Added September 29, 2011 Translating...TranslateChinese SimplifiedChinese TraditionalEnglishFrenchGermanItalianPortugueseRussianSpanishTurkish This is segmentation fault 11 a computer translation of the original content. It is provided for general information only and should not be relied upon as complete or http://stackoverflow.com/questions/4428679/fortran-bus-error-when-modifying-parameter accurate. Share Tweet Share Problem : When I run my code compiled with the Intel Fortran Compiler I get 'sigsegv' on linux (or sigbus on Mac OS X). This code has run fine for years on
Fortran compiler. -fdump-fortran-originalOutput the internal parse tree after translating the source program into internal representation. Only really useful for debugging the GNU Fortran compiler itself. -fdump-fortran-optimizedOutput the parse tree after https://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html front-end optimization. Only really useful for debugging the GNU Fortran compiler itself. http://www.glue.umd.edu/afs/glue.umd.edu/system/info/olh/Utilities/Unix_answers/unix_bus_or_seg.html -fdump-parse-treeOutput the internal parse tree after translating the source program into internal representation. Only really useful for debugging the GNU Fortran compiler itself. This option is deprecated; use -fdump-fortran-original instead. -ffpe-trap=listSpecify a list of floating point exception traps to enable. On most systems, if a floating point exception occurs and the segmentation fault trap for that exception is enabled, a SIGFPE signal will be sent and the program being aborted, producing a core file useful for debugging. list is a (possibly empty) comma-separated list of the following exceptions: ‘invalid’ (invalid floating point operation, such as SQRT(-1.0)), ‘zero’ (division by zero), ‘overflow’ (overflow in a floating point operation), ‘underflow’ (underflow in a floating point operation), ‘inexact’ (loss of fortran debug bus precision during operation), and ‘denormal’ (operation performed on a denormal value). The first five exceptions correspond to the five IEEE 754 exceptions, whereas the last one (‘denormal’) is not part of the IEEE 754 standard but is available on some common architectures such as x86. The first three exceptions (‘invalid’, ‘zero’, and ‘overflow’) often indicate serious errors, and unless the program has provisions for dealing with these exceptions, enabling traps for these three exceptions is probably a good idea. Many, if not most, floating point operations incur loss of precision due to rounding, and hence the ffpe-trap=inexact is likely to be uninteresting in practice. By default no exception traps are enabled. -ffpe-summary=listSpecify a list of floating-point exceptions, whose flag status is printed to ERROR_UNIT when invoking STOP and ERROR STOP. list can be either ‘none’, ‘all’ or a comma-separated list of the following exceptions: ‘invalid’, ‘zero’, ‘overflow’, ‘underflow’, ‘inexact’ and ‘denormal’. (See -ffpe-trap for a description of the exceptions.) By default, a summary for all exceptions but ‘inexact’ is shown. -fno-backtraceWhen a serious runtime error is encountered or a deadly signal is emitted (segmentation fault, illegal instruction, bus error, float
program yourself, you can skip the rest of this section. For College-supported software, you can report the bug by contacting a consultant through olc or "mail staff". ------------------------------------------------------------------------------- If the program displays this message: Bus error or Segmentation fault or Core dump ... then the program was trying to access a memory location outside its address space. The computer detected this problem and sent a signal to your program, which caused it to abort. Things that cause bus errors and segmentation violations are typically out-of-bounds array references and/or references through uninitialized or mangled pointers. Look very closely in your program for bizarre things like that. A common example in C is: int c; scanf("%d", c); instead of the correct version: int c; scanf("%d", &c); An example from C++ is: int* p=new int[100]; cout<< p[100]; instead of the correct version: int* p=new int[100]; cout << p[99] (remember array referances in C and C++ start with 0 ) There are a number of methods for finding out where the program went out of bounds. One method is to use printf() statements to determine how far the program is getting before it crashes, and to print out the contents of interesting variables. A more sophisticated method is using 'dbx', a source level symbolic debugger. C and C++ programmers can also use 'gdb'. To learn about 'dbx', you can read the manual pages by using the 'man' command, as in: man dbx To learn about 'gdb', you can read the manual node in the 'xinfo' program, or using 'M-x info' in Emacs. If you need to debug your program, you may want to enable a core dump. Usually, those two messages above would also have "(core dumped)" by them, indicating that the program wrote an image of its current memory into a file called "core" in that directory. You might want to type 'fs lq' and find out how many blocks (kilobytes) you have available in your quota. Then you can type, say: limit coredumpsize 100 .. to limit your core dump size to 100K for your current login. BE CAREFUL