- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Difference between Segmentation fault Bus error Me...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2004 04:08 PM
08-15-2004 04:08 PM
I compiled this program on HP-UX PA-RISC,Linux and HP-UX IPF machines.
main()
{
char *p;
*p='a';
printf("%c",*p);
}
Linux machine1 Segmentation fault
Linux Machine2 Segmentation fault
HP UX PA-RISC Machine1 Bus error(coredump)
HP UX PA-RISC Machine2 Bus error(coredump)
HP UX IPF Machine1 Memory fault(coredump)
HP UX IPF Machine2 Memory fault(coredump)
So what is the difference between
1. Segmentation fault
2. Bus error(coredump)
3. Memory fault(coredump)
4. Coredump
How can I reproduce these errors independent of platforms ( may be compilers ) or Can I get 4/3 C programs for each of the errors.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2004 05:27 PM
08-15-2004 05:27 PM
Re: Difference between Segmentation fault Bus error Memory fault coredump
At present your code fails when the end of the
string (that has not been established) is
searched for. Now depending on how the compiler
compiled the code, it may or may not find a
terminating 0 befor the OS jumps on it for
trying to reference memory out of its own area. So its possible that this code may
even work in some cases or some times.
It all depends on the initial value of 'p' and
if the compiler set it or left it as a random value.
At least setting p=0 would be reproducable.
The way the OS responds to this will also
depend on the memory model used in the OS I believe.
Not sure that helps, but any time you want
to run some code with errors in it I'm sure
there are plenty of people that can provide
samples ;{)
Why do you need to reproduce the errors anyway?
...Laurie :{)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2004 06:21 PM
08-15-2004 06:21 PM
Re: Difference between Segmentation fault Bus error Memory fault coredump
As far as I know
Segmentation fault occurs when we try to access the memory area out of the process address space.
Bus error occurs when we try to access a physical device that does not exists.
coredump is the facility provided by the compiler that will give us the information on the causes and memory faults that occurs at run time.
My question is to know these things ( the above mentioned 4 cases ) practically.
Now I have a program for bus error.
#include
main()
{
FILE *fp=NULL;
fwrite("TEST",5,1,fp);
fclose(fp);
}
But this produced the expected result in IPF and PA-RISC machineS alone . In Linux I am not getting the bus error message. Instead I am getting the same "Segmentation fault" error message.
What I need is, four programs ( or three programs, if coredump has been excluded ) which when run on all the platforms produces the same results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2004 11:05 PM
08-15-2004 11:05 PM
SolutionThe "Memory fault" you are seeing is also a Segmentation Fault... only ksh and posix-sh use the term for that very same thing.
ksh# sleep 100&
[1] 2901
ksh# kill -SEGV %%
[1] + Memory fault(coredump) sleep 100&
csh# sleep 100 &
[1] 2961
csh# kill -SEGV %%
[1] Segmentation fault sleep 100 (core dumped)
A bus error usually happens if you are using unaligned addresses. The NULL pointer example is a special case... one of many.
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2004 11:52 PM
08-15-2004 11:52 PM
Re: Difference between Segmentation fault Bus error Memory fault coredump
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2004 03:36 AM
08-16-2004 03:36 AM
Re: Difference between Segmentation fault Bus error Memory fault coredump
With the signal we can identify the problem. You can simply use file core to know the type of signal you got there.
Causes for SEGV and BUS signals:
SIGSEGV
SEGV_MAPERR address not mapped to object
SEGV_ACCERR invalid permissions for mapped object
SIGBUS
BUS_ADRALN invalid address alignment
BUS_ADRERR non-existent physical address
BUS_OBJERR object specific hardware error
Segmentation fault and Memory fault (coredump) are same. All are happenening because of SIGSEGV signal.
Bus error is happenening out on getting SIGBUS signal.
Let us compare them on HP-UX platforms:
IPF: <11.23>
First program is giving only Memory fault(coredump) on IPF and BUS error on PA-RISC.
When we try it as,
FILE *fp;
and getting Bus error(coredump) on IPF and PA-RISC too.
I hope the messages of SIGSEGV and SIGBUS will give the view on this.
Memory errors are occured because unaligned memory area access or invalid address mappings too.
You can use gdb / adb to debug the core.
And more use file / what commands to analyse