From: Eric McDonald <mcdonald@phy.cmich.edu>
To: Lincoln Peters <sampln@sbcglobal.net>
Cc: Xconq list <xconq7@sources.redhat.com>
Subject: Re: Unstable pre-release version of enhanced ai_plan_research
Date: Wed, 08 Sep 2004 18:02:00 -0000 [thread overview]
Message-ID: <413EC26D.8080400@phy.cmich.edu> (raw)
In-Reply-To: <1094615804.4338.58970.camel@localhost>
Lincoln Peters wrote:
> uWeight = malloc( 2 * numAdvances );
I would suggest:
uweight = (int *)xmalloc(num_advances * sizeof(int));
Xconq's 'xmalloc' checks to see if the 'malloc' succeeded. If it failed,
then 'run_error' is invoked. 'xmalloc' also scrubs the allocated memory
to be 0 everywhere.
Furthermore, the problem could be here, because you allocate an array of
2-byte slots, but you declared the storage type as an 'int' which is
likely 4 bytes on your system. So, if 'numAdvances' is 4, then you
allocate 8 bytes, but when you do 'uWeight[3]', you are accessing the
12th through 15th bytes! Ooops.
> for_all_advance_types(count1) {
> uWeight[count1] = 0;
The problem could be here. Your 'count1' variable iterates from 0 to
'numatypes', but the array is only allocated with 'numAdvances'
positions. 'numAdvances' <= 'numatypes'. You have to worry about the <
case, because that is a potential source of your crash.
> } else if ( ua_multiply_production( count3, count1 ) < 1 ) {
> uWeight[count2] -= 1.0 / ua_multiply_production( count3, count1 );
> }
The above snippet is a potential divide by zero case. Also, the
righthand side evaluates to a floating point value, whereas the storage
on the lefthand side is of an integer type. Furthermore, a factor of 1.0
is internally 100 in Xconq, so to get a reciprocal, you can do:
uweight[count2] -= 10000 / ua_multiply_production(count3, count1);
Eric
prev parent reply other threads:[~2004-09-08 8:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-08 4:09 Lincoln Peters
2004-09-08 18:02 ` Eric McDonald [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=413EC26D.8080400@phy.cmich.edu \
--to=mcdonald@phy.cmich.edu \
--cc=sampln@sbcglobal.net \
--cc=xconq7@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).