Sponsored Content
Full Discussion: Bus Error
Top Forums UNIX for Dummies Questions & Answers Bus Error Post 10252 by Perderabo on Saturday 10th of November 2001 04:57:39 PM
Old 11-10-2001
Quote:
Originally posted by tonyt
I only know that if one trys to access a memory which in a readonly segment, the system will bumpup a Bus Error signal.
By "access" I guess you mean trying to store something there. Not to belabor the obvious, but it is legal to read a read-only segment.

There are two signals that can be delivered to a process that attempts something with an illegal memory address:

SIGBUS (ksh will say Bus error(coredump))
SIGSEGV (ksh will say Memory fault(coredump))

I've been looking through my library and I can't find any documentation that states which signal must be delivered under a specific condition. It may be that some versions of unix only use one or the other for everything. The kernel really depends on the cpu to catch these and it may be that some cpu's simply have a single trap to handle all bad addresses.

Still to me these errors have slightly different meanings, although I must admit that this is based mostly on C programming in an HP-UX environment.

SIGBUS means that you have asked to cpu to do something that is impossible. More to the point, the cpu can catch this error immediately by looking at the virtual address. There is no need to even attempt to convert the virtual address to a physical address. This is why cpu's bother to have a two-tiered check on an address. Converting a virtual address to a physical address can be a somewhat expensive operation.

SIGSEGV means that you have asked the cpu to do something that is illegal. If the kernel wanted to, it could fiddle with things to render the attempted operation legal. This error is caught after the attempted conversion of the virtual address to a physical address.

I would tend to expect that the situation tonyt is describing would result in a SIGSEGV rather than a SIGBUS....except that if you have a pointer that is both misaligned and in the wrong segment, you won't get both signals, you only get a SIGBUS. If an int is 4 bytes on your system and you try to store an int at random addresses in a read-only segment, then yes 75% of the time you will get a SIGBUS, while 25% of the time your pointer is aligned and you get the SIGSEGV.

Still tonyt may have a system that works differently than mine. And if a system can only deliver a single signal for address problems, SIGBUS would be my choice.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bus error on solaris

Hi there I am running soalris 9 on a sun fire 480r and all of a sudden (today) whenever the users run the command `top` we get the following message `bus error` does anybody have any information on what this is all about and whether there is a routine i can perform to gather more... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

2. UNIX for Dummies Questions & Answers

Bus error(coredump

aix 5.3 ML1 system was functioing well, when suddenly telnet session hung and then I got the following message "Bus error(coredump)" would appreciate if anyone would assist as to what to do next. (3 Replies)
Discussion started by: Student37
3 Replies

3. UNIX for Advanced & Expert Users

Bus Error(coredump)

Hi, I am using HP-UX. While i try to run the Sqlplus command using the shel script in encounter the following error: <shell script name>: some number Bus Error(coredump) What may be the reason behind this. I read few previous threads in this forum where i found some similar case. There it was... (2 Replies)
Discussion started by: Jayesh
2 Replies

4. Programming

BUS error

Hi! I've got a program which runs fine under Linux, but I have compiled it to run under SunOS 5.8 in a Sparc computer, and now it sometimes fails with "bus error". Ussing gdb I surfed to the error line, which is *pointer = some_vector; where some_vector is a 16 byte struct (4 integers)... (1 Reply)
Discussion started by: shesatmine
1 Replies

5. UNIX for Dummies Questions & Answers

bus error (coredump)

Hi all, I am getting bus error problem in SunOS. Can you please help me out in this regard. Actually, my entire code till the last line has been executed. But after tht i am getting a bus error. Please help me. Thanks in advance. Charu. (4 Replies)
Discussion started by: charu
4 Replies

6. HP-UX

Need help on Bus error(coredump)

Hi all, I am quite weak in C but I need to get some work done. Hope someone can help me out. I keep getting this error when i try to run my C application in my HP-UX 10.20 machine. Some code snippet: Month(DBTime) =====This is a function which will return variable "CutOffTime" to be use... (5 Replies)
Discussion started by: Vision©
5 Replies

7. HP-UX

Bus Error

I am getting bus error when i include "#!/bin/ksh". If i remove interpreter then script is working. Can anyone explain this and how can i avoid this error? Operating System is HP-UX B.11.23 U 9000/800 1091834454 (2 Replies)
Discussion started by: anbu23
2 Replies

8. Programming

Bus error

Hi everyone, I have a GUI project and when I run it and left in idle state for a long time(there is nothing done, just opened GUI, no more actions),I get bus error after trying to do anything with it. I've tried to build it in debug mode and use gdb, but I don't get any error in debug mode.It... (3 Replies)
Discussion started by: sisi
3 Replies

9. Programming

Bus error in tree insertion

Hi, I am new to C++ and unix. I am trying to write a programm for inserting elements into a binary tree. To get the code flow I used few Couts and m facing buss error while insertion. Below is the code snippet. explainations needed. thanks :) #include <iostream.h> struct mytree { int... (1 Reply)
Discussion started by: vineetjoshi
1 Replies

10. Programming

Bus Error: 10...Help please!

Hi all, I am writing a phonebook program to store names and number using a list. Here is the code for the function which allows the user to enter the name and number (where the error occurs). //THIS FUNCTION ADDS A NEW ENTRY TO THE phonebook_list void insert(void){ //variables int... (5 Replies)
Discussion started by: kdejan
5 Replies
PHYS(2) 							System Calls Manual							   PHYS(2)

NAME
phys - allow a process to access physical addresses SYNOPSIS
phys(segreg, size, physadr) DESCRIPTION
The argument segreg specifies a process virtual (data-space) address range of 8K bytes starting at virtual address segregx8K bytes. This address range is mapped into physical address physadrx64 bytes. Only the first sizex64 bytes of this mapping is addressable. If size is zero, any previous mapping of this virtual address range is nullified. For example, the call phys(6, 1, 0177775); will map virtual addresses 0160000-0160077 into physical addresses 017777500-017777577. In particular, virtual address 0160060 is the PDP-11 console located at physical address 017777560. This call may only be executed by the super-user. SEE ALSO
PDP-11 segmentation hardware DIAGNOSTICS
The function value zero is returned if the physical mapping is in effect. The value -1 is returned if not super-user, if segreg is not in the range 0-7, if size is not in the range 0-127, or if the specified segreg is already used for other than a previous call to phys. BUGS
This system call is obviously very machine dependent and very dangerous. This system call is not considered a permanent part of the sys- tem. ASSEMBLER
(phys = 52.) sys phys; segreg; size; physadr PDP11 PHYS(2)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy