Path: thunder.mcrcim.mcgill.edu!bonnie.concordia.ca!news-server.csri.toronto.edu!utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Bus error (core dumped) ? Message-ID: <1991Oct7.170711.13248@zoo.toronto.edu> Date: 7 Oct 91 17:07:11 GMT References: <12459@bunny.GTE.COM> <6537@inews.intel.com> <1991Oct6.025006.18886@cbnews.cb.att.com> Organization: U of Toronto Zoology Lines: 43 In article <1991Oct6.025006.18886@cbnews.cb.att.com> junk1@cbnews.cb.att.com (eric.a.olson) writes: >>In general (and this may vary) a bus error means you've >>tried to read or write a location that simply doesn't >>exist, and the hardware complained. Its close buddy, the >>segmentation violation, means you've tried to read or write >>a location protected by the OS ... > > My manual says the opposite. A segmentation violation occurs > when you reference an address not in your process' address space. > (wild pointer). A bus error occurs when you attempt to write > at an unwriteable address (like address 0). The PDP did get a > hardware 'bus timeout error' when addressing unaligned data... Okay, time to sort this out. The pdp11 lumped a number of things into trap 4 ("bus error"): illegal instruction (mostly jump to a register; unimplemented or unknown instructions used a different trap entirely), bus timeout (attempt to reference a nonexistent *physical* address), odd word address (attempt to reference a 16-bit word not on a word boundary), stack limit overflow (you don't want to know), microbreak (you really don't want to know), and attempt to execute HALT in user mode. Some of the later 11s in fact had a CPU Error Register that would tell you what specific problem caused a trap 4! Trap 250 ("segmentation violation") specifically meant that the MMU did not like what you just tried to do. This typically meant reference to a nonexistent *virtual* address or attempt to write a readonly region. In practice, a bus error in a user program almost invariably meant an attempt to reference a word at an odd address. The only way to get a bus timeout from a user program was if the operating system had given the program access to a section of the physical address space that was not fully populated. Normal pdp11 Unixes did not do this. Unixes on later machines have had to decide how to map their own machine's internal errors into the somewhat limited set of signals. Typically, but not necessarily universally, "segmentation violation" still means you did something forbidden by the MMU -- access to a nonexistent virtual address or an attempt to violate protection restrictions -- while bus error means you did something the CPU itself didn't like, such as an unaligned access to a multibyte object. -- Programming graphics in X is like | Henry Spencer @ U of Toronto Zoology finding sqrt(pi) using Roman numerals. | henry@zoo.toronto.edu utzoo!henry