Linux Bus Error Debug
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the bus error c++ workings and policies of this site About Us Learn more about Stack bus error linux Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs bus error (core dumped) linux Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join how to debug bus error them; it only takes a minute: Sign up What is a bus error? up vote 156 down vote favorite 49 What does the "bus error" message mean, and how does it differ from a segfault? c unix segmentation-fault bus-error share|improve this question edited Oct 18 '15 at 10:44 Cool Guy 15.7k51952 asked Oct 17 '08 at 14:48 raldi 7,272216178
How To Solve Bus Error In Linux
add a comment| 15 Answers 15 active oldest votes up vote 151 down vote accepted Bus errors are rare nowadays on x86 and occur when your processor cannot even attempt the memory access requested, typically: using a processor instruction with an address that does not satisfy its alignment requirements. Segmentation faults occur when accessing memory which does not belong to your process, they are very common and are typically the result of: using a pointer to something that was deallocated. using an uninitialized hence bogus pointer. using a null pointer. overflowing a buffer. PS: To be more precise this is not manipulating the pointer itself that will cause issues, it's accessing the memory it points to (dereferencing). share|improve this answer edited Oct 17 '08 at 15:18 answered Oct 17 '08 at 15:12 bltxd 5,72322336 52 They aren't rare; I'm just at Exercise 9 from How to Learn C the Hard Way and already encountered one... –11684 Mar 26 '13 at 20:12 5 Another cause of bus errors (on Linux anyway) is when the opera
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 more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us
Bus Error Vs Segmentation Fault
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community bus error core dumped c Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Debugging SIGBUS bus error 10 mac on x86 Linux up vote 9 down vote favorite 2 What can cause SIGBUS (bus error) on a generic x86 userland application in Linux? All of the discussion I've been able to find online is regarding memory alignment errors, which from what http://stackoverflow.com/questions/212466/what-is-a-bus-error I understand doesn't really apply to x86. (My code is running on a Geode, in case there are any relevant processor-specific quirks there.) linux debugging bus-error sigbus share|improve this question asked Jan 18 '10 at 20:58 Josh Kelley 34.4k1375147 add a comment| 6 Answers 6 active oldest votes up vote 12 down vote accepted You can get a SIGBUS from an unaligned access if you turn on the unaligned access trap, but normally that's off on an x86. You can also get it from accessing http://stackoverflow.com/questions/2089167/debugging-sigbus-on-x86-linux a memory mapped device if there's an error of some kind. Your best bet is using a debugger to identify the faulting instruction (SIGBUS is synchronous), and trying to see what it was trying to do. share|improve this answer answered Jan 18 '10 at 21:10 Chris Dodd 2,274710 1 The debugger showed that the SIGBUS occurred immediately upon entering the function. Maybe I have some memory corruption, or maybe one of the function parameters is bad? I'll have to check the disassembly in the debugger for more details if the error occurs again. –Josh Kelley Jan 18 '10 at 22:13 1 @Josh -- check to see what the actual failing instruction is -- if its a push or pop, then your stack pointer is corrupted. If its something else, then the address in the instruction is the issue. –Chris Dodd Jan 19 '10 at 19:04 add a comment| up vote 14 down vote SIGBUS can happen in Linux for quite a few reasons other than memory alignment faults - for example, if you attempt to access an mmap region beyond the end of the mapped file. Are you using anything like mmap, shared memory regions, or similar? share|improve this answer answered Jan 19 '10 at 0:10 caf 155k14193324 2 Yes, we're using shared memory regions. I'll investigate that possibility the next time this error comes up. Thanks. –Josh Kelley Jan 19 '10 at 13:20 add a comment| up vote 2 down vote Oh yes there's one more weird way to ge
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 http://www.glue.umd.edu/afs/glue.umd.edu/system/info/olh/Utilities/Unix_answers/unix_bus_or_seg.html 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 https://docs.oracle.com/cd/E19455-01/806-1075/msgs-1097/index.html 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 bus error 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 linux bus error 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 not to let yourself go over quota, as you would then not be able to create or edit files. You should delete the "core" file when you don't need
has received a signal indicating that it attempted to perform I/O to a device that is restricted or that does not exist. This message is usually accompanied by a core dump, except on read-only file systems. Action Use a debugger to examine the core file and determine what program fault or system problem led to the bus error. If possible, check the program's output files for data corruption that might have occurred before the bus error. Technical Notes Bus errors can result from either a programming error or device corruption on your system. Some common causes of bus errors are: invalid file descriptors, unreasonable I/O requests, bad memory allocation, misaligned data structures, compiler bugs, and corrupt boot blocks. Previous: Broken pipeNext: "C" © 2010, Oracle Corporation and/or its affiliates