From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Sep 4 21:00:09 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B236F10656B8 for ; Sat, 4 Sep 2010 21:00:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 873F68FC18 for ; Sat, 4 Sep 2010 21:00:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o84L09hu066538 for ; Sat, 4 Sep 2010 21:00:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o84L09bG066525; Sat, 4 Sep 2010 21:00:09 GMT (envelope-from gnats) Resent-Date: Sat, 4 Sep 2010 21:00:09 GMT Resent-Message-Id: <201009042100.o84L09bG066525@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Pascal Stumpf Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 255C610656B9 for ; Sat, 4 Sep 2010 20:56:11 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 14FC18FC15 for ; Sat, 4 Sep 2010 20:56:11 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o84KuA00018620 for ; Sat, 4 Sep 2010 20:56:10 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o84KuAC7018583; Sat, 4 Sep 2010 20:56:10 GMT (envelope-from nobody) Message-Id: <201009042056.o84KuAC7018583@www.freebsd.org> Date: Sat, 4 Sep 2010 20:56:10 GMT From: Pascal Stumpf To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/150287: Segfault: games/spider crashes after 51 moves X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2010 21:00:09 -0000 >Number: 150287 >Category: ports >Synopsis: Segfault: games/spider crashes after 51 moves >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Sep 04 21:00:09 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Pascal Stumpf >Release: 8-STABLE amd64 >Organization: >Environment: >Description: Spider crashes with a segfault in movelog.c in the record() function after grow_cache() is called from there the first time (i.e. when move_index reaches 50): record(from, dest, num_cards, exposed) int from, dest, num_cards; Bool exposed; { int val; val = 11 * ( 11 * ((exposed ? 1 : 0) * 14 + num_cards) + dest) + from; move_cache[move_index++] = val; if (move_index >= cache_size) grow_cache(); } So there has to be something weird happening in grow_cache(). I’ve got no idea what it is. Usage of realloc() seems ok to me. :( grow_cache() { int *new; cache_size += CACHE_SIZE; new = (int *) realloc((char *)move_cache, (unsigned)(cache_size * sizeof(int))); if (new == (int *) NULL) { (void)fprintf(stderr,"realloc failed\n"); exit(-1); } move_cache = new; } As a dirty workaround, one could just increase the initial CACHE_SIZE. >How-To-Repeat: >Fix: --- movelog.c.orig 2010-09-04 22:32:24.000000000 +0200 +++ movelog.c 2010-09-04 22:32:39.000000000 +0200 @@ -23,7 +23,7 @@ #include #endif -#define CACHE_SIZE 50 +#define CACHE_SIZE 1000 static int move_index = 0; static int *move_cache = NULL; static int cache_size = 0; >Release-Note: >Audit-Trail: >Unformatted: