From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20449 invoked by alias); 8 Sep 2004 08:27:39 -0000 Mailing-List: contact xconq7-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: xconq7-owner@sources.redhat.com Received: (qmail 20392 invoked from network); 8 Sep 2004 08:27:37 -0000 Received: from unknown (HELO sccrmhc12.comcast.net) (204.127.202.56) by sourceware.org with SMTP; 8 Sep 2004 08:27:37 -0000 Received: from [192.168.181.128] (c-67-172-156-222.client.comcast.net[67.172.156.222]) by comcast.net (sccrmhc12) with ESMTP id <2004090808273701200ibfp5e>; Wed, 8 Sep 2004 08:27:37 +0000 Message-ID: <413EC26D.8080400@phy.cmich.edu> Date: Wed, 08 Sep 2004 18:02:00 -0000 From: Eric McDonald User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) MIME-Version: 1.0 To: Lincoln Peters CC: Xconq list Subject: Re: Unstable pre-release version of enhanced ai_plan_research References: <1094615804.4338.58970.camel@localhost> In-Reply-To: <1094615804.4338.58970.camel@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004/txt/msg01141.txt.bz2 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