From owner-freebsd-questions@FreeBSD.ORG Tue Aug 12 15:02:52 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC002106566C for ; Tue, 12 Aug 2008 15:02:52 +0000 (UTC) (envelope-from jordi@cdmon.com) Received: from correo.cdmon.com (correo.cdmon.com [212.36.74.112]) by mx1.freebsd.org (Postfix) with ESMTP id A37508FC08 for ; Tue, 12 Aug 2008 15:02:52 +0000 (UTC) (envelope-from jordi@cdmon.com) Received: from localhost (localhost.cdmon.com [127.0.0.1]) by correo.cdmon.com (Postfix) with ESMTP id 5A4D5130D79 for ; Tue, 12 Aug 2008 17:02:51 +0200 (CEST) X-Spam-Flag: NO X-Spam-Score: 0.657 X-Spam-Level: X-Spam-Status: No, score=0.657 required=5.9 tests=[AWL=-1.691, BAYES_50=0.001, FH_HOST_ALMOST_IP=1.751, SPF_SOFTFAIL=0.596] Received: from correo.cdmon.com ([127.0.0.1]) by localhost (correo.cdmon.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cVTuRObhQzLz for ; Tue, 12 Aug 2008 17:02:44 +0200 (CEST) Received: from [192.168.0.174] (62.Red-217-126-43.staticIP.rima-tde.net [217.126.43.62]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by correo.cdmon.com (Postfix) with ESMTP id DA6C61310C4 for ; Tue, 12 Aug 2008 17:02:43 +0200 (CEST) Message-ID: <48A1A613.5020407@cdmon.com> Date: Tue, 12 Aug 2008 17:02:43 +0200 From: Jordi Moles Blanco User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: error allocating memory with realloc(). how can i increase max_allowed in the system? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: jordi@cdmon.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Aug 2008 15:02:52 -0000 Hi, i'm running a FreeBSD 7.0 amd64 machine and struggling with some C code i'm writing. I've had some trouble with this home-made script as it keeps crashing while launching a "realloc()" call. I narrowed down the problem and here i'm sending you a short example of code that crashes: ************* #include #include int main() { int midataula; midataula = 3000; char *missatge = (char *)malloc(midataula * sizeof(char)); missatge[0]='h'; missatge[1]='o'; missatge[2]='l'; missatge[3]='a'; printf("\n\ntaula1: %s",missatge); int voltes; voltes = 0; while(voltes<4) { midataula = midataula+500; realloc(missatge, midataula * sizeof(char)); voltes++; } printf("\n\ntaula2: %s",missatge); } ************* this is a full "working" you can compile on your machine. Like this... i get "Segmentation fault (core dumped)" but if instead of "while(voltes<4)" i use "while(voltes<3)" the script works fine with this output: ********** taula1: hola taula2: hola ********** so... i guess there must be a limit in the system somewhere. I've tried to reset all variables that i've seen in the "sysctl -a" list refering to malloc, memory, mem, and so on... but so far i haven't fixed the problem. i'm running this script as root and in the /etc/login.conf file there's only the "default" group with the "unlimited" values. A part from that, if i perform a "limit" call, i get this: ************* # limit cputime unlimited filesize unlimited datasize 33554432 kbytes stacksize 524288 kbytes coredumpsize unlimited memoryuse unlimited vmemoryuse unlimited descriptors 45000 memorylocked unlimited maxproc 22500 sbsize unlimited ************* i've tried to resize datasize and stacksize, but the system won't let me do so. any idea how to solve this? thanks.