Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Unexpected Results

Reply
Thread Tools

Unexpected Results

 
 
arpit
Guest
Posts: n/a
 
      12-05-2007

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

 
Reply With Quote
 
 
 
 
Mark Bluemel
Guest
Posts: n/a
 
      12-05-2007
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>".

 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      12-05-2007
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.

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      12-05-2007
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

 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      12-05-2007
arpit <(E-Mail Removed)> writes:

> 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
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-05-2007
arpit <(E-Mail Removed)> writes:
> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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"
 
Reply With Quote
 
arpit
Guest
Posts: n/a
 
      12-06-2007
On Dec 6, 3:32 am, Keith Thompson <(E-Mail Removed)> wrote:
> arpit <(E-Mail Removed)> writes:
> > 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) (E-Mail Removed) <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





 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-06-2007
arpit <(E-Mail Removed)> writes:
> On Dec 6, 3:32 am, Keith Thompson <(E-Mail Removed)> wrote:
>> arpit <(E-Mail Removed)> writes:
>> > 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) <(E-Mail Removed)>
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"
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      12-06-2007
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.
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      12-06-2007
[comp.lang.c] Keith Thompson <(E-Mail Removed)> wrote:

> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page inherting from .master - unexpected results =?Utf-8?B?QXJ0?= ASP .Net 0 05-26-2006 01:13 AM
Unexpected timing results Steven D'Aprano Python 7 02-24-2006 11:10 AM
Unexpected performance results Dave C++ 1 04-08-2004 07:06 PM
thread vs threading -- Unexpected Results CK Python 3 12-06-2003 03:22 AM
Re: unexpected results Scott Lander Perl 0 07-07-2003 02:28 PM



Advertisments