Penguin
Diff: CommonProgrammingBugs
EditPageHistoryDiffInfoLikePages

Differences between version 9 and revision by previous author of CommonProgrammingBugs.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 9 Last edited on Friday, November 5, 2004 3:02:04 pm by JohnMcPherson Revert
Older page: version 7 Last edited on Monday, September 15, 2003 9:28:01 am by SamJansen Revert
@@ -3,18 +3,20 @@
  
 To diagnose this problem, compile everything with __-g__ (and probably [-Wall] as well) and link it all with electric fence (__-lefence__). 
  
 eg: 
- [gcc|gcc(1)] -g [-Wall] broken.cc -o broken.o  
- gcc -lefence broken.o -o broken 
+ <tt> [gcc|gcc(1)] -g [-Wall] broken.cc -o broken.o</tt><br>  
+ <tt> gcc -lefence broken.o -o broken</tt>  
  
 Check your ulimit(1) is not set to 0 (as is the default on most recent distros). 
  ulimit -c unlimited 
 This allows your program to dump core. 
  
 then run your program 
+<verbatim>  
  ./broken 
  Segmentation Fault (core dumped) 
+</verbatim>  
 If you don't get the "(core dumped)" bit, then your ulimit is wrong, or you don't have write access to the current working directory, or the disk is full etc. 
  
 Now that you have the program and the core file, use it to figure out where your program cored 
  gdb ./broken ./core 
@@ -24,15 +26,15 @@
 bt full will take the __b__ack __t__race of the core file and if you specify "full" it'll show you all the variables along the way. 
  
 The first line should be the place where your bug occured. If you look at this line you'll probably find you're doing something silly (like addressing past the end of an array, or using a pointer that has been free()'d). 
  
-Other neat tools for diagnosing memory errors are :  
-* [Valgrind]  
-* electric fence  
-* [MMGR] (works well with C ++)  
-* [mcheck] (part of libc6 -dev)  
-* [MALLOC_CHECK_] environment variable  
-* [LD_DEBUG] environment variable  
-* [DMALLOC|http://www .dmalloc .com]  
-* printf(3)  
-* catchsegv (prints the backtrace of a program that segfaults) - don't forget to compile with __ -g__ if you want file names and line numbers  
-* AddToMe: any other neat tools you know of?  
+!!!ld : ''name'': hidden symbol `__dso_handle' in /.../crtbegin.o is referenced by DSO  
+You are linking against a shared library that was created incorrectly.  
+  
+Eg this happens with gcc/g ++ version 3 if you create a shared library directly using  
+ <tt>ld -shared -o libfoo.so ...</tt>  
+You should instead use  
+ <tt>g++ -shared -Wl,-soname,libfoo .so .1 -o libfoo.so ...</tt>  
+  
+  
+----  
+See our DeBugging page for more details.