473,786 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Segmentation Fault

I just finish writing LAB2 with no errors when compiling, but once i run
it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!

Nov 14 '05 #1
21 8309
us**@domain.inv alid spoke thus:
I just finish writing LAB2 with no errors when compiling, but once i run
it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


You inadvertently drew a pentagram on your screen and thereby summoned
The Lord of Vague Usenet Postings, causing your error. That's just a
guess, however. Another guess is that LAB2, whatever the heck it was,
involved pointers or memory allocation, and that you messed it up.
"Segmentati on fault" means that you did something wrong, but nothing
more can be gleaned from it without looking at your code. If you post
it, someone may be kind enough to help you.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2
us**@domain.inv alid wrote:

I just finish writing LAB2 with no errors when compiling,
but once i run it, i get "segmentati on fault"
.. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


Write the smallest similar program that compiles
and gives the same runtime error. Then post the code.

--
pete
Nov 14 '05 #3
On Fri, 6 Feb 2004 us**@domain.inv alid wrote:
I just finish writing LAB2 with no errors when compiling, but once i run
it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


It means you made a mistake in your program. The fix is to stop writing
bad code. Without further information I cannot be more specific.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@ whitehouse.gov
Nov 14 '05 #4
us**@domain.inv alid wrote:
I just finish writing LAB2 with no errors when compiling, but once i run
it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


Stop dereferencing invalid pointers.
--
Martin Ambuhl
Nov 14 '05 #5
>> I just finish writing LAB2 with no errors when compiling, but once i run
it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


Stop dereferencing invalid pointers.


What a guess :)
Do the statistics say so that it's most likely to be an invalid pointer?
Nov 14 '05 #6
"Jan Engelhardt" <je*****@linux0 1.gwdg.de> wrote in message
news:Pi******** *************** *******@yvahk01 .tjqt.qr...
I just finish writing LAB2 with no errors when compiling, but once i run it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
tell me what it means and how i can fix it? thx!


Stop dereferencing invalid pointers.


What a guess :)
Do the statistics say so that it's most likely to be an invalid pointer?


Yes. The statistics show that 100% of segmentation faults are caused by
derefencing an invalid pointer.
Nov 14 '05 #7
Peter Pichler wrote:
"Jan Engelhardt" <je*****@linux0 1.gwdg.de> wrote in message
news:Pi******** *************** *******@yvahk01 .tjqt.qr...
>> I just finish writing LAB2 with no errors when compiling, but once i run >> it, i get "segmentati on fault".. i don't know what is wrong, can anyoen
>> tell me what it means and how i can fix it? thx!
>
>Stop dereferencing invalid pointers.


What a guess :)
Do the statistics say so that it's most likely to be an invalid pointer?


Yes. The statistics show that 100% of segmentation faults are caused by
derefencing an invalid pointer.


$ cat recurse.c
int main() { return main(); }
$ gcc -ansi -pedantic recurse.c
$ ./a.out
Segmentation fault

Jeremy.
Nov 14 '05 #8
"Jeremy Yallop" <je****@jdyallo p.freeserve.co. uk> wrote in message
news:sl******** ***********@heh e.cl.cam.ac.uk. ..
Peter Pichler wrote:

Yes. The statistics show that 100% of segmentation faults are caused by
derefencing an invalid pointer.


$ cat recurse.c
int main() { return main(); }
$ gcc -ansi -pedantic recurse.c
$ ./a.out
Segmentation fault


Your example involves dereferencing an invalid pointer.
Nov 14 '05 #9
Peter Pichler wrote:
"Jeremy Yallop" <je****@jdyallo p.freeserve.co. uk> wrote in message
news:sl******** ***********@heh e.cl.cam.ac.uk. ..
Peter Pichler wrote:
>
> Yes. The statistics show that 100% of segmentation faults are caused by
> derefencing an invalid pointer.


$ cat recurse.c
int main() { return main(); }
$ gcc -ansi -pedantic recurse.c
$ ./a.out
Segmentation fault


Your example involves dereferencing an invalid pointer.


Really? At which point, and for what reason, does the pointer become
invalid?

Jeremy.
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6812
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script works fine and do all what I need. But at the end of the execution, I can read "Segmentation Fault". The segmentation fault appear at the end of my script execution,
3
1939
by: diyanat | last post by:
i am writing a cgi script in C using the CGIC library, the script fails to run, i am using apache on linux error report from apache : internal server error Premature end of script headers: /var/www/cgi-bin/script.cgi when i debug the program i get Segmentation fault gdb ./script.cgi
16
8996
by: laberth | last post by:
I've got a segmentation fault on a calloc and I don'tunderstand why? Here is what I use : typedef struct noeud { int val; struct noeud *fgauche; struct noeud *fdroit; } *arbre; //for those who don't speak french arbre means tree.
3
11445
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc () from /lib/tls/libc.so.6 It's really strange; I just call malloc() like "tmp=malloc(size);" the system gives me Segmentation fault I want to write a code to do like a dynamic array, and the code is as
5
2998
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I understood that a segmentation fault can occur whenever I declare a pointer and I leave it un-initialized. So I thought the problem here is with the (const char *)s in the stuct flightData (please note that I get the same fault declaring as char * the...
18
26121
by: Digital Puer | last post by:
Hi, I'm coming over from Java to C++, so please bear with me. In C++, is there a way for me to use exceptions to catch segmentation faults (e.g. when I access a location off the end of an array)? Thanks.
27
3372
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! #include <stdlib.h> #include <stdio.h> typedef struct _node_t {
7
5881
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our testcases we experiance Segmentation fault from the python libraries. If i know how to handle the exception for Segmentation fault , it will help me complete the run on any testcase , even if i experiance Seg Fault due to any one or many functions in...
3
5187
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection from 10g release2 PHP is configured with the following parameters './configure' '--prefix=/opt/oracle/php' '--with-apxs=/opt/oracle/apache/bin/apxs' '--with-config-file-path=/opt/oracle/apache/conf' '--enable-safe-mode' '--enable-session'...
6
5045
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on gcc. The only difference is that in first I only call "main" and in second call
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.