Debugging Solaris Bus Error
Contents |
I'm not pointing my finger at gcc here, this is a Sun gotcha).Here's an example program (simplified for something much bus error (core dumped) linux more complex that I was debugging), that illustrates how memory alignment bus error (core dumped) centos on SPARC systems can bite you if you are doing low-level things in C. In the example the bus error core dumped c++ program allocates space for a thing structure which will be prepended with a header. The header structure has a dummy byte array called data which will be used bus error core dumped in unix to reference the start of the thing.struct thing { int an_int;};struct header { short id; char data[0];};struct header * maker( int size ) { return (struct header *)malloc( sizeof( struct header ) + size );}int main( void ) { struct header * a_headered_thing = maker( sizeof( struct thing ) ); struct thing * a_thing = (struct thing *)&(a_headered_thing->data[0]);
Bus Error Core Dumped Solaris
a_thing->an_int = 42;}If you build this on a SPARC machine you'll get the following error when you run it:Bus Error (core dumped)Annoyingly, if you build a debugging version of this program the problem magically goes away and doesn't dump core in the debugger. So you either resort to printf-style debugging or going into gdb and looking at the assembly output.Here's what happens when you run this in gdb (non-debug code):(gdb) runProgram received signal SIGSEGV, Segmentation fault.0x000106d8 in main ()Since you can't get back to the source we're forced to do a little disassembly:(gdb) disassembleDump of assembler code for function main:0x000106b0
challenged and removed. (July 2015) (Learn how and when to remove this template message) In computing, a bus error is a fault raised by hardware, notifying an operating system (OS) that a process is trying to access memory that the CPU cannot physically address: an
How To Fix Bus Error (core Dumped)
invalid address for the address bus, hence the name. In modern use on most architectures bus error core dumped solaris 10 these are much rarer than segmentation faults, which occur primarily due to memory access violations: problems in the logical address or permissions. On POSIX-compliant bus error (core dumped) python platforms, bus errors usually result in the SIGBUS signal being sent to the process that caused the error. SIGBUS can also be caused by any general device fault that the computer detects, though a bus error rarely means http://blog.jgc.org/2007/04/debugging-solaris-bus-error-caused-by.html that the computer hardware is physically broken—it is normally caused by a bug in a program's source code.[citation needed] Bus errors may also be raised for certain other paging errors; see below. Contents 1 Causes 1.1 Non-existent address 1.2 Unaligned access 1.3 Paging errors 2 Example 3 References Causes[edit] There are at least three main causes of bus errors: Non-existent address[edit] Software instructs the CPU to read or write a specific physical memory address. Accordingly, the CPU https://en.wikipedia.org/wiki/Bus_error sets this physical address on its address bus and requests all other hardware connected to the CPU to respond with the results, if they answer for this specific address. If no other hardware responds, the CPU raises an exception, stating that the requested physical address is unrecognized by the whole computer system. Note that this only covers physical memory addresses. Trying to access an undefined virtual memory address is generally considered to be a segmentation fault rather than a bus error, though if the MMU is separate, the processor can't tell the difference. Unaligned access[edit] Most CPUs are byte-addressable, where each unique memory address refers to an 8-bit byte. Most CPUs can access individual bytes from each memory address, but they generally cannot access larger units (16 bits, 32 bits, 64 bits and so on) without these units being "aligned" to a specific boundary (the x86 platform being a notable exception). For example, if multi-byte accesses must be 16 bit-aligned, addresses (given in bytes) at 0, 2, 4, 6, and so on would be considered aligned and therefore accessible, while addresses 1, 3, 5, and so on would be considered unaligned. Similarly, if multi-byte accesses must be 32-bit aligned, addresses 0, 4, 8, 12, and so on would be considered aligned and therefore accessible, and all addresses in between would be considered unaligned. Attempting to access a unit larger th
Bus error 6Contributors 13Replies 14Views 7 YearsDiscussion Span 7 Years Ago Last Post by sanushks 0 7 Years Ago Hi All, I'm running a C code on cygwin compiled with gcc, the code basically does file processing, it runs fine on my PC, but when run on a Solaris machine, it gives Bus error and https://www.daniweb.com/programming/software-development/threads/192520/core-dump-bus-error core dumps. Is it a known issue? If not, is there any way i can debug the http://cboard.cprogramming.com/networking-device-communication/92284-solaris-10-bus-errors-when-compiling-some-programs-debug-info.html core file? The file i'm trying to process is 45MB in size. I'm newbie with using the debuggers. Any suggestions are welcome Thanks Santosh sanushks 25 33 posts since Oct 2008 Community Member c 0 Salem 5,138 7 Years Ago Did you recompile all the code on your solaris machine? Or did you simply copy the .exe file and hoped it would work. IT WON'T. > Is it a bus error known issue? Yes, your code has bugs. 0 abbas1707 7 Years Ago yes you have to compile code for solaris platform also. 0 Discussion Starter sanushks 25 7 Years Ago Hi, I did recompile. Is it possible for the code to have bugs, if yes, y didn't it core dump on the cygwin too? 0 abbas1707 7 Years Ago it seems platform dependency issue 1 John A 1,896 7 Years Ago >Is it possible for the code to have bugs Yes. >y didn't it core dump bus error (core on the cygwin too? Different platform, different system, different architecture. But if you *really* want to find out the reason, you'll have to post some code, because our guessing isn't going to get you very far. Comments jephthah: random guessing is the fun part of debugging 0 Discussion Starter sanushks 25 7 Years Ago Hi, Its a 800 line code, can i post it here? Or could i send it as a attachment? 0 Salem 5,138 7 Years Ago Definitely better as an attachment, but 800 lines is probably a bit much for a forum. Some of us would probably have a quick look for some of the obvious mistakes. But if it's involved, it's several hours work on just one problem. Do you have a debugger on the solaris box? Yes, you can use a debugger to examine (not interact with) a core file, but this is "last resort" territory. It's a post mortem on a corpse. Compiling the code with debug, then running that in the debugger will tell you a lot more (the patient is intensive care, but still alive). Setting breakpoints at suspect areas of code for example will allow you to see what's really going on. 0 Discussion Starter sanushks 25 7 Years Ago the problem is the code is working fine until a certain point.. I mean it processes about 24,000 records before it fails.. So will it help setting breakpoints.. N i'm not familiar with debugging 0 Discussion Starter sanushks 25 7 Years Ago I'm in the process of install
Programming Boards Networking/Device Communication Solaris 10: bus errors when compiling some programs with debug info Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Solaris 10: bus errors when compiling some programs with debug info Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 08-01-2007 #1 BooBoo808 View Profile View Forum Posts Registered User Join Date Jun 2007 Location Rome, NY Posts 24 Solaris 10: bus errors when compiling some programs with debug info Well, lately I have been having a go at a simple client/server app on a Solaris 10 machine. So far, it hasn't been fun. Now I have been reading how picky Solaris can be with memory alignment, and I even wrote a few test programs to see how they can fail (purposly mis-aligning a struct ). However, for the server I am writing, when ever I try to compile it using -g to include debugging symbols gdb crashes with a bus error. Now I know it says gdb was configured on Solaris 2.8 (below), but it seemed to be working with other simple apps I was debugging. So here is what I am seeing: Code: jaws% gcc -Wall -g -lnsl -lsocket -lresolv DataPassServer.c -o dps jaws% gdb dps GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "sparc-sun-solaris2.8"...Bus Error Now, before I go posting tons of code, I am wondering if there is a more general solution. I am using all the normal network functions and structs just as I did a year ago when I did beejs nework programming guide. I am going to copy his program directly and see if I can debug that. I know lots of people run into memory alignment issues on Solaris, but I guess my question is, why does gdb die with a bus error when it trys to load my program with the included debug symbols? I haven't progressed far with the program for this reason. At this point, I can run the program (with both debugging symbols included and excluded) and it seems to run fine. However it only binds and then listens on a port, so its quite simplistic. If anyo