Sponsored Content
Top Forums Programming Reason for Segmentation fault Post 302142354 by matrixmadhan on Thursday 25th of October 2007 04:55:09 PM
Old 10-25-2007
Quote:
Originally Posted by porter
Then the bit of memory that 'p' ends up pointing to has the contents 0x55.

If you have an uninitialised pointer it is just that, uninitialised, and will have the contents of whatever memory was at that point in the stack. As luck would have it, the &ch[0] did not trap and neither did accessing p.
Yes exactly as you had said.

And with this argument it is not guaranteed that the code would never crash.

To simulate that I could spawn this code between several process so that there could be an instance in the stack frame where there would be no value pointed to by ' p ' and ultimately crashing
 

10 More Discussions You Might Find Interesting

1. Programming

segmentation fault

hi all i'm trying to execute a c program under linux RH and it gives me segmentation fault, this program was running under unix at&t anybody kow what the problem could be? thanx in advance regards (2 Replies)
Discussion started by: omran
2 Replies

2. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

3. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

4. UNIX for Dummies Questions & Answers

Segmentation Fault

Hi, While comparing primary key data of two tables thr bteq script I am getting this Error. This script is a shell script. *** Error: The following error was encountered on the output file. Script.sh: 3043492 Segmentation fault(coredump) Please let me know how to get through it. ... (5 Replies)
Discussion started by: monika
5 Replies

5. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

6. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

7. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

8. Homework & Coursework Questions

Segmentation Fault

this is a network programming code to run a rock paper scissors in a client and server. I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault. -the segmentation fault is fixed Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies

9. Programming

Segmentation fault

I keep getting this fault on a lot of the codes I write, I'm not exactly sure why so I'd really appreciate it if someone could explain the idea to me. For example this code #include <stdio.h> main() { unsigned long a=0; unsigned long b=0; int z; { printf("Enter two... (2 Replies)
Discussion started by: sizzler786
2 Replies

10. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
_UNW_getGR(3X)															    _UNW_getGR(3X)

NAME
_UNW_getGR(), _UNW_getAR(), _UNW_getAlertCode(), _UNW_getBR(), _UNW_getCFM(), _UNW_getFR(), _UNW_getGR_NaT(), _UNW_getIP(), _UNW_getKernel- SavedContext(), _UNW_getPR(), _UNW_getPreds(), _UNW_clearAlertCode() - query values in unwind library data structure SYNOPSIS
DESCRIPTION
returns the value of a numbered general register num in the object pointed to by parameter p. returns the value and NaT bit of a numbered general register num in the object pointed to by parameter p. The values are returned via a structure of type The structure's value field contains the register value and the structure's NaT field contains the register NaT bit. returns the value of a numbered floating point register num in the object pointed to by parameter p. The values are returned via a struc- ture of type The structure's first_container and second_container fields contain the two consecutive double words of the Floating point register Spill/Fill memory format. See returns the value of a numbered branch register num in the object pointed to by parameter p. returns the value of an enumerated application register num in the object pointed to by parameter p. The enumeration type is used for accessing application registers. returns the value of a numbered predicate register num in the object pointed to by parameter p. returns the value of all predicate registers in the object pointed to by parameter p. The returned value contains the value of each predi- cate register in the bit corresponding to the predicate register number -- for instance, bit 63 contains the value for predicate register 63. returns the contents of the instruction pointer in the object pointed to by parameter p. returns the contents of the current frame marker in the object pointed to by parameter p. returns the most recently encountered "client needs to know" return code. If no "client needs to know" conditions have been encountered, returns "Client needs to know" return codes are all of the enumerators in the enumeration with the exception of clears any "client needs to know" return code in the object pointed to by parameter p. provides the means for a tool such as a kernel debugger to obtain some of the information it needs about a kernel interruption. The values are returned via a structure of type structure from which the client can obtain the two fields, and of the format P10 unwind descriptor. For more detail, refer to unwind(5) and to RETURN VALUE
Except for the register value query functions (which are functions with prefix return the requested values on successful completion or a value equivalent to 0 otherwise. returns values from the enumeration See on unwind(5). returns on successful completion. Otherwise returns when is not in one of the following states: Init, User_Interrupted_Frame, User_Send- sig_Frame, Kernel_Bottom_Frame, Frame. EXAMPLES
Tead the value of General Register 5 in this procedure frame's context; check for range errors, query errors, etc.; then finally clear the alert code: WARNINGS
See the table in unwind(5), section subsection which lists when the values returned by the query functions are guaranteed to reflect the actual register values of the given procedure's processor state. Scratch register values, for example, are valid only after crossing a stack frame associated with an interruption. See "Chapter 5: Register Usage". AUTHOR
and were developed by HP. SEE ALSO
U_STACK_TRACE(3X), _UNW_createContextForSelf(3X), _UNW_currentContext(3X), unwind(5). Integrity Systems Only _UNW_getGR(3X)
All times are GMT -4. The time now is 06:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy