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 1nIYCH-00021Q-HK for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 15:50:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIYCG-00021S-Aw for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 15:50:56 +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 1nIYCE-00021I-Dy for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 15:50:56 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIYCA-0008Kh-Bo for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 15:50:54 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 21FEE3200EE0; Fri, 11 Feb 2022 10:50:46 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 11 Feb 2022 10:50:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; bh=gJQaLVolohWUos EMaZw+F7ISKN+qmQXw8K7ABAii7CY=; b=b6f/NUrEF45avUue0Oeb2ZcdR4DFf8 CQu3v59xQ6iMlGFqfjtV0cxxWhKmrm12EdXfwqv6TYGe4+DhPS2meOTt3m5qKnXP Pqx4hAPF/922CnL34zAP+bB+BcyVwBXk28xCvE9CX9zGZ5FYA+98gKpF3pUE4o9y zAKLwyyr8D9+qM7Y5K8CCt8dMztTBE3gUcl8tROXFknhGWvOccV132lsULjXCw7k 3Qgm5p23wZ989yIIzHXzwqNZNkGtHk6Yq2NFbXmhNUvzUt4Lhr46K+ft9cgD0zmq dcsidEZaiFdYTwDe86kWNuks4oCbBi21GpusM04B7093RdSHqjAFtolA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=gJQaLVolohWUosEMaZw+F7ISKN+qmQXw8K7ABAii7 CY=; b=Q1fvht/igNJIPK4g+a+8PgfUlC/g0W2i03M7+i0v4MdC0veJBy+K0viEq PXgFemVBo1Noi75YlM5Rw19LQMciPSGKWOYfU9WE8AbFYLkXVPs2sARjmVuTsVHk bGaAosqrG1lmc3Jg77S6gExE1LuhIalIDyUi3L7W0cGnq4dnFmjVvKQEFCzbjF2L cBJvFhegyYcn5dijpTHewanAvpPzXF6ZnYArtr2ux9n9Z8DTJM1JUP/6tCz8sF4F c84MSc5yzWDzdODDpjYgic2LVQWPZ131RQV97nJK6rkbflQmeTPniL+vXsLf/2fW VFIlSTqZAKppfZrTx5tMNIlJg+PLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrieefgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggugfgjsehtkeertddttddunecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeejheeivdevffeijeffheegfeejveffteeviedugeegtdehffdvffekudek tdehjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 11 Feb 2022 10:50:45 -0500 (EST) Date: Fri, 11 Feb 2022 07:50:44 -0800 From: Andres Freund To: Juan =?utf-8?B?Sm9zw6kgU2FudGFtYXLDrWE=?= Flecha Cc: PostgreSQL Hackers Subject: Re: pg_receivewal.exe unhandled exception in zlib1.dll Message-ID: <20220211155044.x75ziw7cvbb5p23h@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-02-11 16:33:11 +0100, Juan José Santamaría Flecha wrote: > If you execute pg_receivewal.exe with the option "--compression-method > gzip" it will fail with no error. You can see an error in the db log: > > 2022-02-10 11:46:32.725 CET [11664][walsender] [pg_receivewal][3/0:0] LOG: > could not receive data from client: An existing connection was forcibly > closed by the remote host. > > Tracing the execution you can see: > > Unhandled exception at 0x00007FFEA78C1208 (ucrtbase.dll) in An invalid > parameter was passed to a function that considers invalid parameters fatal. > ucrtbase.dll!00007ff8e8ae36a2() Unknown > > zlib1.dll!gz_comp(gz_state * state, int flush) Line 111 C > zlib1.dll!gz_write(gz_state * state, const void * buf, unsigned __int64 > len) Line 235 C > pg_receivewal.exe!dir_write(void * f, const void * buf, unsigned __int64 > count) Line 300 C > pg_receivewal.exe!ProcessXLogDataMsg(pg_conn * conn, StreamCtl * stream, > char * copybuf, int len, unsigned __int64 * blockpos) Line 1150 C > pg_receivewal.exe!HandleCopyStream(pg_conn * conn, StreamCtl * stream, > unsigned __int64 * stoppos) Line 850 C > pg_receivewal.exe!ReceiveXlogStream(pg_conn * conn, StreamCtl * stream) > Line 605 C > pg_receivewal.exe!StreamLog() Line 636 C > pg_receivewal.exe!main(int argc, char * * argv) Line 1005 C > > The problem comes from the file descriptor passed to gzdopen() in > 'src/bin/pg_basebackup/walmethods.c'. Using gzopen() instead, solves the > issue without ifdefing for WIN32. Please find attached a patch for so. I hit this as well. The problem is really caused by using a debug build of postgres vs a production build of zlib. The use different C runtimes, with different file descriptors. A lot of resources in the windows world are unfortunately tied to the C runtime and that there can multiple C runtimes in a single process. Greetings, Andres Freund