From owner-freebsd-current Fri Aug 9 0:14: 3 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F1F0E37B405 for ; Fri, 9 Aug 2002 00:13:56 -0700 (PDT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0000C43E75 for ; Fri, 9 Aug 2002 00:13:55 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.3/8.12.2) with ESMTP id g797B2De010594; Fri, 9 Aug 2002 09:11:03 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: "Andrey A. Chernov" Cc: current@freebsd.org Subject: Re: phk malloc() sometimes forget to set errno In-Reply-To: Your message of "Thu, 08 Aug 2002 03:27:52 +0400." <20020807232750.GA1168@nagual.pp.ru> Date: Fri, 09 Aug 2002 09:11:02 +0200 Message-ID: <10593.1028877062@critter.freebsd.dk> From: Poul-Henning Kamp Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <20020807232750.GA1168@nagual.pp.ru>, "Andrey A. Chernov" writes: >I found at least one case: Try this patch: Index: malloc.c =================================================================== RCS file: /home/ncvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.70 diff -u -r1.70 malloc.c --- malloc.c 30 May 2002 21:59:16 -0000 1.70 +++ malloc.c 9 Aug 2002 07:12:53 -0000 @@ -1093,6 +1093,7 @@ wrtwarning("recursive call\n"); malloc_active--; THREAD_UNLOCK(); + errno = EPERM; return (0); } if (!malloc_started) @@ -1108,6 +1109,8 @@ THREAD_UNLOCK(); if (malloc_xmalloc && !r) wrterror("out of memory\n"); + if (!r) + errno = ENOMEM; return (r); } @@ -1120,6 +1123,7 @@ wrtwarning("recursive call\n"); malloc_active--; THREAD_UNLOCK(); + errno = EPERM; return; } if (ptr != ZEROSIZEPTR) @@ -1142,6 +1146,7 @@ wrtwarning("recursive call\n"); malloc_active--; THREAD_UNLOCK(); + errno = EPERM; return (0); } if (ptr && !malloc_started) { @@ -1170,6 +1175,8 @@ THREAD_UNLOCK(); if (malloc_xmalloc && err) wrterror("out of memory\n"); + if (err) + errno = ENOMEM; return (r); } -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message