Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Compiling with debugger flag -g fixes SEGfault (fortran90) Post 302481526 by Corona688 on Friday 17th of December 2010 07:57:01 PM
Old 12-17-2010
Quote:
Originally Posted by drbones
So the title kinda says it all. I was getting a SEGfault, so I decided to compile with the -g option to find where, and low and behold the SEGfault doesn't occur.

I suppose the answer is "Problem solved! You fixed yet another SEGfault." But I am very curious how this could have happened.
Enabling debugging likely disabled some optimizations, altering the way the code was generated and perhaps the pattern of memory use.

Imagine you're using an uninitialized variable. It may just happen to always be zero when the code isn't optimized since it wasn't used before. But optimize it and it decides it doesn't need a variable at all and puts it in a register! Suddenly you're using an uninitialized register, which could be anything, and it crashes...

Or you're overflowing the end of an array, and the arrangement of memory is different when the executable's optimized. When it's not optimized, you might be corrupting empty space and not care. When it's optimized, you could be munging something important, like pointers to somewhere else, or even your stack frame...

Can you debug it when it's not compiled for debugging? The information you get might be limited, but limited's better than nothing.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Linux] How Do I Run Until Segfault

Hello, sorry if this has been posted before but i was wondering if there is a way to run a program until a segmentation fault is found. Currently i'm using a simple shell script which runs my program 100 times, sleeps 1 second because srand(time(0)) is dependent on seconds. Is there a possible... (1 Reply)
Discussion started by: aslambilal
1 Replies

2. Programming

how to avoid the segfault from Address 0x1cd00000103 out of bounds

After allocating memory for some variables, segfault is often to happen, due to the same reason: Address 0x1cd00000103 out of bounds It is welcome to recommend some treatments. Thanks e.g. is_done = 0x1cd00000103 <Address 0x1cd00000103 out of bounds>, hood = 0x23c00000247, c =... (11 Replies)
Discussion started by: cdbug
11 Replies

3. Solaris

Working around netscape 4.9 segfault on Solaris 8

We have a Solaris 8 server which users login to via VNC to get a desktop. On that desktop these users use Netscape Communicator 4.9 to access a very important mail account. Unfortunately Netscape has started segfaulting regularly. Does anyone have any ideas how I can try to find out what point... (1 Reply)
Discussion started by: aussieos
1 Replies

4. Programming

2 Problems: Segfault on ctrl+c and syslog() prob

1. Even if i have the handles for ctrl+c it gives off a segfault 2. syslog doesn't log LOG_ERR event with log masked specified or non specified, it logs LOG_WARNING however... #include <sys/types.h> /* include this before any other sys headers */ #include <sys/stat.h> #include <fcntl.h>... (2 Replies)
Discussion started by: james2432
2 Replies

5. Programming

id3lib SEGFAULT

Hello everyone, I'm writing a program using the id3lib unfortunately I've encountered with memory issue that cause segmentation fault. I tried to rerun and analyze the program with valgrind but it doesn't point me anywhere. I really stuck on this one. Valgrind output: ==14716== Invalid read of... (2 Replies)
Discussion started by: errb
2 Replies

6. Programming

Is Drive Valid Segfault

I have a program that allows users to specify the debug log file location and name. I have tried using the access() and stat() but they both segfault if the drive say (d:\) is invalid. Both seem to be fine if the drive exists. Could someone please point me in the direction to a function that... (1 Reply)
Discussion started by: robfwauk
1 Replies

7. Programming

Alternative debugger to GNU insight debugger

GNU insight debugger is not available now a days and it is required to debug/inspect assembly code as written in the book Assembly Language Programming step by step in Linux so my question is; is there any alternative to insight that I can use instead of insight in which I can get the same... (5 Replies)
Discussion started by: vectrum
5 Replies

8. Programming

segfault in pointer to string program

hello all, my question is not about How code can be rewritten, i just wanna know even though i am not using read only memory of C (i have declared str) why this function gives me segfault :wall:and the other code executes comfortably though both code uses same pointer arithmetic. ... (4 Replies)
Discussion started by: zius_oram
4 Replies

9. Programming

String array iteration causing segfault

I am populating an array of string and print it. But it going in infinite loop and causing segfault. char Name = { "yahoo", "rediff", "facebook", NULL }; main(int argc, char* argv) { int j = 0; ... (7 Replies)
Discussion started by: rupeshkp728
7 Replies

10. Programming

Segfault When Parsing Delimiters In C

Another project, another bump in the road and another chance to learn. I've been trying to open gzipped files and parse data from them and hit a snag. I have data in gzips with a place followed by an ip or ip range sort of like this: Some place:x.x.x.x-x.x.x.x I was able to modify some code... (6 Replies)
Discussion started by: Azrael
6 Replies
dwz(1)							      General Commands Manual							    dwz(1)

NAME
       dwz - DWARF optimization and duplicate removal tool

SYNOPSIS
       dwz [OPTION...] [FILES]

DESCRIPTION
       dwz  is	a program that attempts to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size, by
       replacing DWARF information representation with equivalent smaller representation where possible and by reducing the amount of  duplication
       using techniques from DWARF standard appendix E - creating DW_TAG_partial_unit compilation units (CUs) for duplicated information and using
       DW_TAG_imported_unit to import it into each CU that needs it.

       The tool handles DWARF 32-bit format debugging sections of versions 2, 3 and 4 and GNU extensions on top of those, though using DWARF 4	or
       worst case DWARF 3 is strongly recommended.

       The  tool  has  two main modes of operation, without the -m option it attempts to optimize DWARF debugging information in each given object
       (executable or shared library) individually, with the -m option it afterwards attempts to optimize even	more  by  moving  DWARF  debugging
       information  entries (DIEs), strings and macro descriptions duplicated in more than one object into a newly created ELF ET_REL object whose
       filename is given as -m option argument.  The debug sections in the executables and shared libraries specified on the command line are then
       modified again, referring to the entities in the newly created object.

OPTIONS
       -m FILE --multifile FILE
	      Multifile  mode.	 After	processing all named executables and shared libraries, attempt to create ELF object FILE and put debugging
	      information duplicated in more than one object there, afterwards optimize each named executable or shared library  even  further	if
	      possible.

       -h --hardlink
	      Look  for  executables  or shared libraries hardlinked together, instead of rewriting them individually rewrite just one of them and
	      hardlink the rest to the first one again.

       -M NAME --multifile-name NAME
	      Specify the name of the common file that should be put into the .gnu_debugaltlink section alongside with its build ID.   By  default
	      dwz puts there the argument of the -m option.

       -r --relative
	      Specify  that  the  name	of  the  common file to be put into the .gnu_debugaltlink section is supposed to be relative path from the
	      directory containing the executable or shared library to the file named in the argument of the -m option.  Either -M  or	-r  option
	      can be specified, but not both.

       -q --quiet
	      Silence up some of the most common messages.

       -o FILE --output FILE
	      This  option  instructs dwz not to overwrite the specified file, but instead store the new content into FILE.  Nothing is written if
	      dwz exits with non-zero exit code.  Can be used only with a single executable or shared library (if there are no arguments  at  all,
	      a.out is assumed).

       -l COUNT --low-mem-die-limit COUNT
	      Handle executables or shared libraries containing more than COUNT debugging information entries in their .debug_info section using a
	      slower and more memory usage friendly mode and don't attempt to optimize that object in multifile mode.  The default is  10  million
	      DIEs.  There is a risk that for very large amounts of debugging information in a single shared library or executable there might not
	      be enough memory (especially when dwz tool is 32-bit binary, it might run out of available virtual address space even sooner).

       -L COUNT --max-die-limit COUNT
	      Don't attempt to optimize executables or shared libraries containing more than COUNT DIEs at all.  The default is 50 million DIEs.

       -? --help
	      Print short help and exit.

ARGUMENTS
       Command-line arguments should be the executables, shared libraries or their stripped to file separate debug information objects.

EXAMPLES
	      $ dwz -m .dwz/foobar-1.2.debug -rh 
		bin/foo.debug bin/foo2.debug foo/lib/libbar.so.debug
       will attempt to optimize debugging information in bin/foo.debug, bin/foo2.debug and lib/libbar.so.debug (by modifying the files	in  place)
       and  when  beneficial  also  will  create  .dwz/foobar-1.2.debug  file.	 .gnu_debugaltlink  section  in  the first two files will refer to
       ../.dwz/foobar-1.2.debug and in the last file to ../../.dwz/foobar-1.2.debug.  If e.g.  bin/foo.debug and  bin/foo2.debug  were	hardlinked
       together initially, they will be hardlinked again and for multifile optimizations considered just as a single file rather than two.
	      $ dwz -o foo.dwz foo
       will not modify foo but instead store the ELF object with optimized debugging information if successful into foo.dwz file it creates.
	      $ dwz *.debug foo/*.debug
       will attempt to optimize debugging information in *.debug and foo/*.debug files, optimizing each file individually in place.
	      $ dwz
       is equivalent to dwz a.out command.

SEE ALSO
       http://dwarfstd.org/doc/DWARF4.pdf , gdb(1).

AUTHORS
       Jakub Jelinek <jakub@redhat.com>.

								   15 June 2012 							    dwz(1)
All times are GMT -4. The time now is 09:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy