473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Seg Faults

Hey guys. I've got a general question here regarding segmentation
faults.

I've got some code that I started working on a few weeks ago which at
the time ran without any problems. In the course of my coding I came
across a segmentation fault and needed to check something in the
original version of the code in hope of finding where I had gone
wrong. However, the original code now seg faults as well! The fault
ocurs in roughly the same place as before as the output from both
versions is identical.

I have tried loading up my original archive over and over but nothing
seems to be working. I am certain the archive is sound as I have been
using it as a reference point over the last few weeks without any
problems.

So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.

Kind Regards,

Matt

Aug 6 '07 #1
6 1273
Matt <ma*****@hotmail.comwrites:
Hey guys. I've got a general question here regarding segmentation
faults.

I've got some code that I started working on a few weeks ago which at
the time ran without any problems. In the course of my coding I came
across a segmentation fault and needed to check something in the
original version of the code in hope of finding where I had gone
wrong. However, the original code now seg faults as well! The fault
ocurs in roughly the same place as before as the output from both
versions is identical.

I have tried loading up my original archive over and over but nothing
seems to be working. I am certain the archive is sound as I have been
using it as a reference point over the last few weeks without any
problems.

So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.

Kind Regards,

Matt
Number 1 "doh" check : are you 100% sure you are executing your
recompiled from archive version? Check your path.

Number 2 "why didn't I think of that" is simply compile your archive
code with a comment in it indicating "test day" or something and run it
in a debugger .... when you run debugger check the "test day" comment is
in your code and run it until it segfaults.
Aug 6 '07 #2
On Mon, 06 Aug 2007 03:17:18 -0700, Matt wrote:
Hey guys. I've got a general question here regarding segmentation
faults.

I've got some code that I started working on a few weeks ago which at
the time ran without any problems. In the course of my coding I came
across a segmentation fault and needed to check something in the
original version of the code in hope of finding where I had gone
wrong. However, the original code now seg faults as well! The fault
ocurs in roughly the same place as before as the output from both
versions is identical.

I have tried loading up my original archive over and over but nothing
seems to be working. I am certain the archive is sound as I have been
using it as a reference point over the last few weeks without any
problems.

So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.
Carefully check that you're never dereferencing a pointer which
doesn't point to memory you own. (Note that doing so does not
always causes a segfault, it may depend on many more conditions
that you could imagine.)
Try to isolate the part which causes the segfault, i.e. write the
smallest possible program which exhibits the problem. This will
usually show you where the problem is, if it doesn't post the
reduced program here.

--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Aug 6 '07 #3
On Aug 6, 6:17 am, Matt <matt...@hotmail.comwrote:
Hey guys. I've got a general question here regarding segmentation
faults.
.....
>
So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.
Without code, people can only offer generalities, like checking
pointers for NULL prior to dereferencing them, not using freed memory,
not using uninitialized pointers, not overwriting bounds of allocated
memory, etc. If you always crash at the same point in the program
(seen by logging/etc), it is usually straightforward to figure out
why. Add some print statements showing the objects in use (pointers,
etc), and figure out the problem that way. If you crash at random
points, that is trickier.

<OT>If you are on a system where a core file is available after a
segmentation fault, that can be helpful. Sometimes you need to enable
this (e.g. via ulimit on linux).

There are also lots of tools that can rescue you. If you always crash
in the same place, running under a debugger, putting a breakpoint
there, and looking at things can help. There are some tools, which
may be available on your system, some free, some not, like valgrind,
electric fence, purify, etc, that can be very nice for tracking down
this sort of problem. If you use glibc, the MALLOC_CHECK_ environment
variable set to 2 can occasionally help too, causes core dump on
bounds overwrites, though only when the memory is actually freed.
</OT>

-David

Aug 6 '07 #4
Army1987 <ar******@nospam.itwrote:
On Mon, 06 Aug 2007 03:17:18 -0700, Matt wrote:
Hey guys. I've got a general question here regarding segmentation
faults.
Finding them can be a painful exercise. If you're not able to spot
your error by examining the code, you might find a program such as
valgrind to be useful - check Google for more details.

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
Aug 6 '07 #5
In <11**********************@b79g2000hse.googlegroups .comMatt <ma*****@hotmail.comwrites:
I've got some code that I started working on a few weeks ago which at
the time ran without any problems. In the course of my coding I came
across a segmentation fault and needed to check something in the
original version of the code in hope of finding where I had gone
wrong. However, the original code now seg faults as well! The fault
ocurs in roughly the same place as before as the output from both
versions is identical.
One explanation is that the original code actually did have the problem,
but due to sheer luck you just never saw it.

--
John Gordon A is for Amy, who fell down the stairs
go****@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

Aug 6 '07 #6
On Aug 6, 3:17 am, Matt <matt...@hotmail.comwrote:
Hey guys. I've got a general question here regarding segmentation
faults.

I've got some code that I started working on a few weeks ago which at
the time ran without any problems. In the course of my coding I came
across a segmentation fault and needed to check something in the
original version of the code in hope of finding where I had gone
wrong. However, the original code now seg faults as well! The fault
ocurs in roughly the same place as before as the output from both
versions is identical.

I have tried loading up my original archive over and over but nothing
seems to be working. I am certain the archive is sound as I have been
using it as a reference point over the last few weeks without any
problems.

So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.

Kind Regards,

Matt

Assuming that "both" version of your code fail then chances are:

-You ran the code under different users, earlier one might have access
to resources that later one does not?
-Resources which were available earlier are gone now?

In both cases you could have a failed open/mmap/ioctl and did not
properly check return value. Then using those bad handle/pointer could
lead to segfault.

Aug 7 '07 #7

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

Similar topics

4
by: stephenma7 | last post by:
Hi, everybody. I am new here. I have encountered these many problems for the last couple of days. I have Linux Fedora Core 3(Gnu G++ 3.4.2), Linux Fedora Core 2 (Gnu G++ 3.3.3), Red Hat 9 (Gnu...
3
by: benben | last post by:
Is there a standard guidline to avoid or minimize page faults when manipulating data collections in C++? ben
2
by: Dave Kirby | last post by:
I am working on a network management program written in python that has multiple threads (typically 20+) spawning subprocesses which are used to communicate with other systems on the network. This...
27
by: Sune | last post by:
Hi! Pre-requisites: ------------------- 1) Consider I'm about to write a quite large program. Say 500 K lines. 2) Part of this code will consist of 50 structs with, say, no more than at most...
1
by: tbatwork828 | last post by:
I've PerfMon-ed our application for several days now and it consistently averages 2000 Page Faults/sec, and accumulates on average about 4 mill page faults during 35 mins. During the same...
4
by: tbatwork828 | last post by:
Related to my other post on Graphics.FillRectangle and a lot of page faults caused by this call... We determine that when Control.DoubleBuffer=true to avoid the flicker effect,...
2
by: Crirus | last post by:
I made a simple test... loaded an image from file and draw it on a form In mouse move, I just refresh the form.... that cause 1 000 000 page faults (as task manager shows) in less than a minute.....
2
by: David Morgan | last post by:
Hi Have 4Gb of RAM and plenty of free disk. Those page faults are for DLLHOST.EXE using ~370Mb RAM. inetinfo.exe has 403,106,036 page faults at the time of writing and is using ~145Mb RAM. ...
3
by: scotp | last post by:
Does anyone know what would cause excessive page faults running the js function below? The most common browser used is IE 6. The page has records that include text & checkbox inputs. Each...
4
by: none | last post by:
I have an ASP.NET application, hosted on two web servers. I am looking for advice on what should be an acceptable level of page faults on these production servers. If the acceptable level is zero,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.