Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jR6YV-0008OC-SL for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2020 04:00:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jR6YU-0003ip-Oq for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2020 04:00:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jR6YU-0003ii-EU for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2020 04:00:10 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jR6YO-0003sh-7D for pgsql-hackers@postgresql.org; Wed, 22 Apr 2020 04:00:10 +0000 Received: by mail-lj1-x22e.google.com with SMTP id f18so713439lja.13 for ; Tue, 21 Apr 2020 21:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=MHMR3GOeKs+qiQz54ub/dlaa0zSQ6cgDSy67R5IKogU=; b=qvIDS3nK9CnGUi/Zz6haBo+eF5xlYSMy34vq5Ft2H3WtYvN0rxnN16c+BUtoQa0fn9 e/kLxYzvCDtV0O4AY0FEEAvaMfcft1wGOhgjsLYPNAjY4neYYx9DKRgK+mlEdZhQ4JeM vYqkZYBVGLhrGJbXvTpT3LqzJ2/ikQTOeGkAZKTX34CPDPJ/5+mN8vjjqakZBpUWeh2b ZvGtbVplay7NZqsi83OYIsqKiNC/vdUGEL1QIVSk7OeA5cwAt7akZ/CVGlasQ90s6tPD hwKtEw9Yr5oXXbK162LNi6E3AJ5euHqdjTdDx84cE0+By0ertbhgt0uAn3U8sNgbV4dI +q/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=MHMR3GOeKs+qiQz54ub/dlaa0zSQ6cgDSy67R5IKogU=; b=SQk+XQN9+Q30Lr0zJUMDirDc9oH3G8zt/c/rAO5j8iiWiB8NWIwVDkgihENrWMO5EA WRcQJSCgn5udwbVR/6iix/S/Q3qbyGfUYRk1JVpo9qXwsf25wv4U1KsPsjNXAxJK29Qg c5BUzVgKgb4sBctKYvunPEgcnazhc+KeZGVj7gKXvcoytyFetr/GPmfufEMpg6HPWjNs cN2yAs85Q+kY6W2c12zEdgPIPV0T1eAXC7I4RVE0n2KTECOHXFp/Y4fo9Y66LPXDpFvd nqv4vH0OIszO4dm5WmSbRl4bQjRoAlZUzRacK86ijSx5lqp+RAjg25HzzUOen8xWVcAP uXUA== X-Gm-Message-State: AGi0PuYs4r10PFkdeF8Gh2pQSMf0eNFgYDNa/R+RM20mUbwJhge7BpB5 L7W3h5P6RgagAvSXdXCvNmiThyss X-Google-Smtp-Source: APiQypKhRUuECyDlLvCU07sIeJTCN6PALoxhoIdQhfRIcIoB2qi5y/iJtR5VC29d0owytG8MOC2bTg== X-Received: by 2002:a2e:9c13:: with SMTP id s19mr6280011lji.5.1587528002815; Tue, 21 Apr 2020 21:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.6.196]) by smtp.gmail.com with ESMTPSA id u16sm3311401ljk.9.2020.04.21.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Apr 2020 21:00:01 -0700 (PDT) Subject: Re: HEAPDEBUGALL is broken To: Peter Eisentraut , pgsql-hackers References: <645c0646-4218-d4c3-409a-a7003a0c108d@2ndquadrant.com> <3070eb7d-e06d-31a0-5b68-4ae088fd146c@gmail.com> From: Alexander Lakhin Message-ID: <8936216c-3492-3f6e-634b-d638fddc5f91@gmail.com> Date: Wed, 22 Apr 2020 07:00:00 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------5B968AA60B5C7D33B230ADE2" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------5B968AA60B5C7D33B230ADE2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 21.04.2020 21:01, Peter Eisentraut wrote: > On 2020-04-19 22:00, Alexander Lakhin wrote: >> To the point, I've tried to use HAVE_ALLOCINFO on master today and it >> failed too: > > Do you have a proposed patch? > As this is broken at least since the invention of the generational allocator (2017-11-23, a4ccc1ce), I believe than no one uses this (and slab is broken too). Nonetheless, HAVE_ALLOCINFO in aset.c is still working, so it could be leaved alone, though the output too chatty for general use (`make check` produces postmaster log of size 3.8GB). I think someone would still need to insert some extra conditions to use that or find another way to debug memory allocations. So I would just remove this debug macro. The proposed patch is attached. Best regards, Alexander --------------5B968AA60B5C7D33B230ADE2 Content-Type: text/x-patch; charset=UTF-8; name="remove-allocinfo.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="remove-allocinfo.patch" diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index c0623f106d2..dd8d7a33a4f 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -50,9 +50,6 @@ #include "utils/memdebug.h" #include "utils/memutils.h" -/* Define this to detail debug alloc information */ -/* #define HAVE_ALLOCINFO */ - /*-------------------- * Chunk freelist k holds chunks of size 1 << (k + ALLOC_MINBITS), * for k = 0 .. ALLOCSET_NUM_FREELISTS-1. @@ -298,21 +295,6 @@ static const MemoryContextMethods AllocSetMethods = { #endif }; -/* ---------- - * Debug macros - * ---------- - */ -#ifdef HAVE_ALLOCINFO -#define AllocFreeInfo(_cxt, _chunk) \ - fprintf(stderr, "AllocFree: %s: %p, %zu\n", \ - (_cxt)->header.name, (_chunk), (_chunk)->size) -#define AllocAllocInfo(_cxt, _chunk) \ - fprintf(stderr, "AllocAlloc: %s: %p, %zu\n", \ - (_cxt)->header.name, (_chunk), (_chunk)->size) -#else -#define AllocFreeInfo(_cxt, _chunk) -#define AllocAllocInfo(_cxt, _chunk) -#endif /* ---------- * AllocSetFreeIndex - @@ -796,8 +778,6 @@ AllocSetAlloc(MemoryContext context, Size size) set->blocks = block; } - AllocAllocInfo(set, chunk); - /* Ensure any padding bytes are marked NOACCESS. */ VALGRIND_MAKE_MEM_NOACCESS((char *) AllocChunkGetPointer(chunk) + size, chunk_size - size); @@ -835,8 +815,6 @@ AllocSetAlloc(MemoryContext context, Size size) randomize_mem((char *) AllocChunkGetPointer(chunk), size); #endif - AllocAllocInfo(set, chunk); - /* Ensure any padding bytes are marked NOACCESS. */ VALGRIND_MAKE_MEM_NOACCESS((char *) AllocChunkGetPointer(chunk) + size, chunk->size - size); @@ -996,8 +974,6 @@ AllocSetAlloc(MemoryContext context, Size size) randomize_mem((char *) AllocChunkGetPointer(chunk), size); #endif - AllocAllocInfo(set, chunk); - /* Ensure any padding bytes are marked NOACCESS. */ VALGRIND_MAKE_MEM_NOACCESS((char *) AllocChunkGetPointer(chunk) + size, chunk_size - size); @@ -1021,8 +997,6 @@ AllocSetFree(MemoryContext context, void *pointer) /* Allow access to private part of chunk header. */ VALGRIND_MAKE_MEM_DEFINED(chunk, ALLOCCHUNK_PRIVATE_LEN); - AllocFreeInfo(set, chunk); - #ifdef MEMORY_CONTEXT_CHECKING /* Test for someone scribbling on unused space in chunk */ if (chunk->requested_size < chunk->size) diff --git a/src/backend/utils/mmgr/generation.c b/src/backend/utils/mmgr/generation.c index 56651d06931..af52616e575 100644 --- a/src/backend/utils/mmgr/generation.c +++ b/src/backend/utils/mmgr/generation.c @@ -178,22 +178,6 @@ static const MemoryContextMethods GenerationMethods = { #endif }; -/* ---------- - * Debug macros - * ---------- - */ -#ifdef HAVE_ALLOCINFO -#define GenerationFreeInfo(_cxt, _chunk) \ - fprintf(stderr, "GenerationFree: %s: %p, %lu\n", \ - (_cxt)->name, (_chunk), (_chunk)->size) -#define GenerationAllocInfo(_cxt, _chunk) \ - fprintf(stderr, "GenerationAlloc: %s: %p, %lu\n", \ - (_cxt)->name, (_chunk), (_chunk)->size) -#else -#define GenerationFreeInfo(_cxt, _chunk) -#define GenerationAllocInfo(_cxt, _chunk) -#endif - /* * Public routines @@ -383,8 +367,6 @@ GenerationAlloc(MemoryContext context, Size size) /* add the block to the list of allocated blocks */ dlist_push_head(&set->blocks, &block->node); - GenerationAllocInfo(set, chunk); - /* Ensure any padding bytes are marked NOACCESS. */ VALGRIND_MAKE_MEM_NOACCESS((char *) GenerationChunkGetPointer(chunk) + size, chunk_size - size); @@ -460,8 +442,6 @@ GenerationAlloc(MemoryContext context, Size size) randomize_mem((char *) GenerationChunkGetPointer(chunk), size); #endif - GenerationAllocInfo(set, chunk); - /* Ensure any padding bytes are marked NOACCESS. */ VALGRIND_MAKE_MEM_NOACCESS((char *) GenerationChunkGetPointer(chunk) + size, chunk_size - size); diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c index c928476c479..e9e962d7674 100644 --- a/src/backend/utils/mmgr/slab.c +++ b/src/backend/utils/mmgr/slab.c @@ -157,22 +157,6 @@ static const MemoryContextMethods SlabMethods = { #endif }; -/* ---------- - * Debug macros - * ---------- - */ -#ifdef HAVE_ALLOCINFO -#define SlabFreeInfo(_cxt, _chunk) \ - fprintf(stderr, "SlabFree: %s: %p, %zu\n", \ - (_cxt)->header.name, (_chunk), (_chunk)->header.size) -#define SlabAllocInfo(_cxt, _chunk) \ - fprintf(stderr, "SlabAlloc: %s: %p, %zu\n", \ - (_cxt)->header.name, (_chunk), (_chunk)->header.size) -#else -#define SlabFreeInfo(_cxt, _chunk) -#define SlabAllocInfo(_cxt, _chunk) -#endif - /* * SlabContextCreate @@ -499,8 +483,6 @@ SlabAlloc(MemoryContext context, Size size) randomize_mem((char *) SlabChunkGetPointer(chunk), size); #endif - SlabAllocInfo(slab, chunk); - Assert(slab->nblocks * slab->blockSize == context->mem_allocated); return SlabChunkGetPointer(chunk); @@ -518,8 +500,6 @@ SlabFree(MemoryContext context, void *pointer) SlabChunk *chunk = SlabPointerGetChunk(pointer); SlabBlock *block = chunk->block; - SlabFreeInfo(slab, chunk); - #ifdef MEMORY_CONTEXT_CHECKING /* Test for someone scribbling on unused space in chunk */ if (slab->chunkSize < (slab->fullChunkSize - sizeof(SlabChunk))) --------------5B968AA60B5C7D33B230ADE2--