473,401 Members | 2,125 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,401 software developers and data experts.

Unexpected Results


Hi All,
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

Although I think it is a kind of Bug , but i wish to know what are
the factors responsible for the bug that some times it is ok and
sometimes it is problem.

looking for suggestions.

Thanks

Dec 5 '07 #1
10 1445
arpit wrote:
Hi All,
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

Although I think it is a kind of Bug , but i wish to know what are
the factors responsible for the bug that some times it is ok and
sometimes it is problem.

looking for suggestions.
Hmm... Where did I put my crystal ball?

<looks around>

Nope - can't find it.

<Inspiration strikes!>

I rolled my magic 8 ball and it said :-

"situation unclear - try
<http://www.catb.org/~esr/faqs/smart-questions.html>".

Dec 5 '07 #2
arpit wrote:
>
Hi All,
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

Although I think it is a kind of Bug , but i wish to know what are
the factors responsible for the bug that some times it is ok and
sometimes it is problem.

looking for suggestions.
Yes the problem is on line 42.

Dec 5 '07 #3
arpit wrote:
>
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

Although I think it is a kind of Bug , but i wish to know what are
the factors responsible for the bug that some times it is ok and
sometimes it is problem.

looking for suggestions.
Correct line 42.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 5 '07 #4
arpit <in**************@gmail.comwrites:
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.
You will need to tell us more about your application and the
problems that it exhibits. If your program is short, post the
code here.
--
Ben Pfaff
http://benpfaff.org
Dec 5 '07 #5
arpit <in**************@gmail.comwrites:
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.
[...]

It's likely that something in your program is invoking undefined
behavior, and you're getting results based on, for example, the
contents of memory that you haven't initialized.

The number of ways this can happen probably isn't infinite, but it's
close enough that there's no point in speculating on the cause without
looking at some code.

Try reducing your program down to something much smaller that still
exhibits the problem.

Another approach is to examine the values of variables as your program
is running (either in a debugger or by adding printf calls); it's
likely that some variable will take on a bad value before you see the
symptoms.

But your question is very close to "My program doesn't work; what's
wrong with it?".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 5 '07 #6
On Dec 6, 3:32 am, Keith Thompson <ks...@mib.orgwrote:
arpit <invincible.ar...@gmail.comwrites:
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

[...]

It's likely that something in your program is invoking undefined
behavior, and you're getting results based on, for example, the
contents of memory that you haven't initialized.

The number of ways this can happen probably isn't infinite, but it's
close enough that there's no point in speculating on the cause without
looking at some code.

Try reducing your program down to something much smaller that still
exhibits the problem.

Another approach is to examine the values of variables as your program
is running (either in a debugger or by adding printf calls); it's
likely that some variable will take on a bad value before you see the
symptoms.

But your question is very close to "My program doesn't work; what's
wrong with it?".

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Well to more clearify the cond.

It is C application which uses A static libarary (VIA std for
gigabit ethernet) The application simply uses the calls of the
library. With that sometimes it is working fine and sometimes did't
work. I run the appliacation in a Cluster.
So now i hope I can expect the possible solutions.As the code is
not that short and with best of my understanding it compiles and links
successfully. well I am using AIX os.
Now suggestions.............

Thanks

Dec 6 '07 #7
arpit <in**************@gmail.comwrites:
On Dec 6, 3:32 am, Keith Thompson <ks...@mib.orgwrote:
>arpit <invincible.ar...@gmail.comwrites:
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.

[...]

It's likely that something in your program is invoking undefined
behavior, and you're getting results based on, for example, the
contents of memory that you haven't initialized.
[...]
>But your question is very close to "My program doesn't work; what's
wrong with it?".
When you post a followup, please trim quoted material that isn't
relevant to your response. In particular, please snip the signature
(the stuff following the "-- " line) unless you're actually commenting
on it.
Well to more clearify the cond.

It is C application which uses A static libarary (VIA std for
gigabit ethernet) The application simply uses the calls of the
library. With that sometimes it is working fine and sometimes did't
work. I run the appliacation in a Cluster.
So now i hope I can expect the possible solutions.As the code is
not that short and with best of my understanding it compiles and links
successfully. well I am using AIX os.
Now suggestions.............
Sorry, that doesn't help.

There are still bazillions of possible causes for the behavior you're
not quite describing, and no possible way for us to guess what the
actual cause might be.

Have you read <http://www.catb.org/~esr/faqs/smart-questions.html>?

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 6 '07 #8
arpit wrote:
....
It is C application which uses A static libarary (VIA std for
gigabit ethernet) The application simply uses the calls of the
library. With that sometimes it is working fine and sometimes did't
work. I run the appliacation in a Cluster.
So now i hope I can expect the possible solutions.As the code is
not that short and with best of my understanding it compiles and links
successfully. well I am using AIX os.
Now suggestions.............
1. Simplify your program as much as possible, while still demonstrating
the problem. Throw out big chunks of the program at first, and then
throw out smaller parts, until you've finally found the simplest
possible program that demonstrates your problem. You will often find
that in the process of simplifying it you'll figure out what the problem is.

2. Post a message to this newsgroup containing ALL of the following items:
* The COMPLETE text of your simplified program, cut and pasted from your
actual source code file(s). Include any headers you wrote. Do NOT leave
anything out. In my experience, any time someone leaves something out,
it's usually something that is critical for figuring out what the
problem is. By definition, you don't know what the problem is, or you
wouldn't need our help. Therefore you can not be trusted to correctly
identify which parts of your program are irrelevant.

* The exact commands that were used to compile, link, and execute your
program, along with any messages which were generated along the way.

* The full evidence which supports your belief that the program is not
working correctly. If it produces any error messages, show us the full
text of those messages - don't describe them, don't summarize them -
give us the FULL text. If it produces output, and that output is
incorrect, display that output - COMPLETELY.

3. Wait for a response.

We're not mind readers or clairvoyants. We can't help you solve your
problem unless you tell us precisely what it is. We might not be able to
help after you tell us, either, but that's life.
Dec 6 '07 #9
[comp.lang.c] Keith Thompson <ks***@mib.orgwrote:
It's likely that something in your program is invoking undefined
behavior, and you're getting results based on, for example, the
contents of memory that you haven't initialized.
The number of ways this can happen probably isn't infinite
Depends on your definition of "ways". If

int main() {
int foo[1];
foo[2]=42;
return 0;
}

is distinct from

int main() {
int foo[1];
foo[3]=42;
return 0;
}

, then there an arbitrary number of "ways" on an arbitrary-precision
machine (depending on the range of size_t), although that's still not
infinite. On the other hand, if

int foo() {
}

int main() {
return foo();
}

is distinct from

int bar() {
}

int foo() {
return bar();
}

int main() {
return foo();
}

, then one can write an infinite number of combinations of functions
that eventually invoke a function that produces undefined behavior.

--
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.
Dec 6 '07 #10
arpit wrote:
Hi All,
I had a C application. Which sometimes gives correct result and
some time worng or no result under the same env. Can anyone tell me
what are the possible reasons for it like memory or something else.
Most likely a bug in the code, but it could also be a HW fault.

Although I think it is a kind of Bug , but i wish to know what are
the factors responsible for the bug that some times it is ok and
sometimes it is problem.
Ill-posted question, can't answer this without speculating.

It could be a side-effect, a race-condition, or a lot of other
possibilities...

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Dec 9 '07 #11

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

Similar topics

2
by: CK | last post by:
I am a "newbie" to python and today I had the need to write a program which generated a lot of tcp connections to a range of addresses (10.34.32.0/22) in order to troubleshoot a problem with a...
3
by: Teddy | last post by:
Hello all According to "Think in C++ Volume2", the code below should run smoothly: #include <iostream> #include <exception> using namespace std; class ex { };
3
by: Eric Anderson Vianet SAO | last post by:
hello all When i tried ´pg_dump -v -f dump.dmp dtbtransporte´ I got the error: pg_dump: restoring data for table tbdmovimento pg_dump: dumping out the contents of table tbdmovimento ...
13
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to remember a report a little while ago about tsearch v2...
6
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am...
10
by: Sean | last post by:
I have a struct that I wrote to test a protocol. The idea I had was to just declare the elements of the struct in the order in which they are sent and received as defined by the protocol. ...
2
by: Martijn Mulder | last post by:
/* GraphicsPath.IsVisible() gives unexpected results. I fill a System.Drawing.Drawing2D.GraphicsPath-object with PointF-structures that define the unit-square (0,0), (1,0), (1,1) and (0,1). Then I...
14
by: dbldeegd | last post by:
My Java Script executes fine on an test HTML page, but on the required page which is php results in an error. the page The script drops in message box when the page is loaded since the script...
13
by: bintom | last post by:
I ran the following simple code in C++ and got unexpected results: float f = 139.4; cout << f; Output: 139.399994;
2
by: =?Utf-8?B?d2R1ZGVr?= | last post by:
I have a website using windows integrated security, with anonymous access turned off. The site is used to query orders from a database and when the search takes a long time, a windows login box...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.