From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 175FF3857C6A for ; Mon, 27 Jul 2020 12:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 175FF3857C6A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4EB8EAFDC; Mon, 27 Jul 2020 12:08:22 +0000 (UTC) Subject: Re: [PATCH] Use size_t for mallinfo fields. To: Szabolcs Nagy Cc: Florian Weimer , libc-alpha@sourceware.org, Andreas Schwab References: <87tuyja59i.fsf@igel.home> <87v9izxwo7.fsf@oldenburg2.str.redhat.com> <87lfjvxv58.fsf@oldenburg2.str.redhat.com> <093814cf-0b7d-1011-08e7-4d5c3e56b423@suse.cz> <20200723143835.GJ7127@arm.com> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <940c96e9-5162-88b7-d765-59656978117d@suse.cz> Date: Mon, 27 Jul 2020 14:08:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200723143835.GJ7127@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jul 2020 12:08:14 -0000 On 7/23/20 4:38 PM, Szabolcs Nagy wrote: > The 07/08/2020 09:24, Martin Liška wrote: >> Subject: [PATCH] Add mallinfo2 function that support sizes >= 4GB. >> >> The current int type can easily overflow for allocation of more >> than 4GB. > > i don't think a new symbol with a similar bad > design as the old one is desirable. > > (i think a good design would allow exposing malloc > internal info without abi and api issues when the > internals change, e.g. no struct field names and > struct layout that are tied to internals. and > supportable by other implementations so whatever > gcc is doing would work elsewhere not just on glibc) Hello. All right, I agree with that. So something like: enum malloc_info { ARENA_BYTES, ... }; size_t get_mallinfo (malloc_info type) ? That would allow adding new enum values that can supported in the future. > > one hack that may be acceptable is to use some > nonsensical value in a mallinfo field to signal that > the fields have new meaning, then the api can work > backward compatibly when all field values are less > than 2G and after that things are broken anyway so > we can switch to some different struct content that > has no overflow issue, but abi compatible with the > old struct (e.g. round up the values to multiples of > 1M), so we don't need a new abi symbol and interposers > continue to work. (but i'm not entirely sure this > is a good idea either) Huh, that's quite hacky approach and I don't like it much :) Let's forget about the old API/ABI and design a new proper one. Martin >