Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoBj1-0004I0-H7 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2018 17:29:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eoBj0-0006h7-Jb for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2018 17:29:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eoBj0-0006gw-3k for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2018 17:29:06 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoBiv-0001H3-J3 for pgsql-hackers@postgresql.org; Tue, 20 Feb 2018 17:29:05 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 298682134A; Tue, 20 Feb 2018 12:29:00 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Tue, 20 Feb 2018 12:29:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=uDX5l5A5QLePIMkHqujKAPy9MLPxs xOY4WEuI/tEJf4=; b=Qw6UyoCv9xAnkgmeJx67V5kTdF0d+OLPNWC5kiahoH7iq Hmq5sUQGqfnATgRM5BTCd9MIwfqdqwt3utM3HBEu5xPxsFIvGFT3PTD3e5y02McH RqZfRyxlYdgXDHm0322PF2mzU9ydjmM7EXDtt32J5CreV6sJX4DdFKCZEl1adeyn XoHrjSZwA6aWCHJGr0k6RIk8DjZr7B8WB47vx1Ro2SxNinIpH6YyMeLLgiHek6Xx 1wyZtpGP5fzogpzUe+2xPoxXuZx6Yc8vaF19LuElx3CWczgLlfSDZ7HGBhXOh3RW OozWDnNTgB8eQhvvZtqaD5dp48Gf6pzvPe9YH1X7g== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id D825F241E0; Tue, 20 Feb 2018 12:28:59 -0500 (EST) Date: Tue, 20 Feb 2018 09:28:58 -0800 From: Andres Freund To: Aleksander Alekseev Cc: PostgreSQL Hackers Subject: Re: [PATCH] Add a few suppression rules for Valgrind Message-ID: <20180220172858.ol7rndl6o7sh3qvr@alap3.anarazel.de> References: <20180220150838.GD18315@e733.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180220150838.GD18315@e733.localdomain> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, > I decided to run the code from master branch under Valgrind and > discovered that it reports some errors. > > There are multiple reports like this one (seems to be a false alarm): > > ``` > Invalid read of size 16 > at 0x605F488: __wcsnlen_sse4_1 (in /usr/lib/libc-2.26.so) > by 0x604F5C2: wcsrtombs (in /usr/lib/libc-2.26.so) > by 0x5FE4C41: wcstombs (in /usr/lib/libc-2.26.so) > by 0x6FFAFC: wchar2char (pg_locale.c:1641) > by 0x6937A0: str_tolower (formatting.c:1599) > by 0x6F88E8: lower (oracle_compat.c:50) > by 0x43097D: ExecInterpExpr (execExprInterp.c:678) > by 0x48B201: ExecEvalExpr (executor.h:286) > by 0x48BBD6: tfuncInitialize (nodeTableFuncscan.c:369) > by 0x48B91E: tfuncFetchRows (nodeTableFuncscan.c:299) > by 0x48B245: TableFuncNext (nodeTableFuncscan.c:65) > by 0x4462E6: ExecScanFetch (execScan.c:95) > Address 0x513adab0 is 7,808 bytes inside a recently re-allocated > block of size 16,384 alloc'd > at 0x4C2CEDF: malloc (vg_replace_malloc.c:299) > by 0x7E2807: AllocSetAlloc (aset.c:934) > by 0x7EF481: palloc (mcxt.c:848) > by 0x42D2A7: ExprEvalPushStep (execExpr.c:2131) > by 0x42D7DB: ExecPushExprSlots (execExpr.c:2286) > by 0x42D723: ExecInitExprSlots (execExpr.c:2265) > by 0x429B77: ExecBuildProjectionInfo (execExpr.c:370) > by 0x44A39B: ExecAssignProjectionInfo (execUtils.c:457) > by 0x4733FE: ExecInitNestLoop (nodeNestloop.c:308) > by 0x4442F0: ExecInitNode (execProcnode.c:290) > by 0x43C5EB: InitPlan (execMain.c:1043) > by 0x43B31C: standard_ExecutorStart (execMain.c:262) These are libc issues, I don't think we should carry exceptions for those. Normally valgrind after a while will catch up and internally ignore them. Here the issue is that the SSE implementation can read a few trailing bytes at the end of the string, which is harmless. Normally valgrind fixes this issue by "intercepting" such libc symbols, but I suspect that some libc optimizations broke that. On my systems I just include a global valgrind suppression file which includes libc specific things and then the postgres valgrind.supp. I'm very hesitant to add suppressions to the codebase for this, seems too likely to actually hide bugs. > ``` > > Also there are many reports like this one (definitely false alarm): > > ``` > Syscall param epoll_pwait(sigmask) points to unaddressable byte(s) > at 0x60A2F90: epoll_pwait (in /usr/lib/libc-2.26.so) > by 0x5F7B24: WaitEventSetWaitBlock (latch.c:1048) > by 0x5F79E8: WaitEventSetWait (latch.c:1000) > by 0x493A79: secure_read (be-secure.c:170) > by 0x4A3DE2: pq_recvbuf (pqcomm.c:963) > by 0x4A3EAA: pq_getbyte (pqcomm.c:1006) > by 0x627AD0: SocketBackend (postgres.c:339) > by 0x628032: ReadCommand (postgres.c:512) > by 0x62D243: PostgresMain (postgres.c:4086) > by 0x581240: BackendRun (postmaster.c:4412) > by 0x5808BE: BackendStartup (postmaster.c:4084) > by 0x57CA20: ServerLoop (postmaster.c:1757) > Address 0x0 is not stack'd, malloc'd or (recently) free'd Yea, this one is just valgrind not really understanding the syscall. It's been fixed in git's source tree: commit 3ac87cf9277964802ddd9af9747a10ff0b838c29 Author: Mark Wielaard Date: 2017-06-17 13:49:22 +0000 epoll_pwait can have a NULL sigmask. we just need a new valgrind release. - Andres