Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vujEp-003TY7-0N for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 03:37:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vujEn-00GjBH-39 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 03:37:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vujEn-00GjB6-2E for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 03:37:29 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vujEk-00000000tie-3RSW for pgsql-hackers@postgresql.org; Tue, 24 Feb 2026 03:37:28 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-7d19bfe1190so4262614a34.1 for ; Mon, 23 Feb 2026 19:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771904247; x=1772509047; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BDJW3XrTYA9v0TrzytBLgXZfCyIxzAjj3m19wtLCqz4=; b=HVFa5K5KMd3ZsGbjnun6QQ2GGnKGNH4v/PkPstWRn9j96LO/upNazOr8Txo62R9146 dHbyB6sCMR/3KMyoH7iEgV8n8hj7T8aYgifZzYypIa7Nz0qit6UPshLiqSliwrrPow4e WbCs3G+qKfdqR6cg+W9khMlK73FRvmJmjxJVjpcdjm67AnGmH9xzDzaIt+8Y1vi1n9Jm z+HvSW7SRQILV7SNt6bUYsPz+t4eSCn539yh/tk+NfIm00Pjrr8DneujzJJlBfK9AGJR nyuDdPz5nU4wxekYusjqaq8T+e0ltJurxbYqC7/0YdWvO9t19XxneSopOGwJXR70KVGq xZZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771904247; x=1772509047; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BDJW3XrTYA9v0TrzytBLgXZfCyIxzAjj3m19wtLCqz4=; b=o3U6ko0gfqrROWx1MOwWDC7i4JKDS1GSGafk6WK0c+ERvR0ZumQvxKw4Cz3SyQWWOT E0GYe11qjtHOO18yPfbnum6uINmgDjsxu+8k5w3dDPe008vEVtdnKAhtxFED22UmT5dv hiJyRCKUGW6LYQH7Kv7sz3zQimmBambRE2Mr02JBS6z7LwdsYY+4HRhHArl0k3aPPpNB h3lQjihzSce+DTU+UQaf9JlepYhqXI5h6K2lYJgV3WCvyVqzZkRkV9fwOgbjWKnqnaPs 713cdQFATVLKCFaEji9DgX0pJJ7d6/60P1Li7nYMJd6QEsh7oCfOw7LBtC0QO2JMCh63 hyTg== X-Forwarded-Encrypted: i=1; AJvYcCWc4CvN7CnoxwBVhrdsyIFEk0Z8iyw8oTlIl+XmKB/GixDPq3WBGCejvqAIdV5YAUowzeNlc8btGwZTN6Xk@postgresql.org X-Gm-Message-State: AOJu0Yz5jq6YCL18/OzGGZTeqwXOQCAsxjmV5nRb7i3BmUOlp6TTVWaI uNOGvXPDji4sDwkVhTiH7M5M86VW0drnEerQJwm9+kxYLNgjOadnc3TR X-Gm-Gg: AZuq6aK2j0ovin4xBUfb+2AVNF1zl6cLb6RouijgfKu2hvrbV22qUAel/B7+rpyVy8i sJNSFLKM6y5NdsmsXY+RlRvNGLmEanWFSxazo0ZdE4S6EpdVwbVUsuyYqylcaR/CO3YLcJACvvK rgdy4S3TXq5SljCUkwrGwQuseoB4/xL3ObGWkn88kUITjL17b7CekniOis8t10la5X90oWDm7rg mdMuO9NAn04TdfO8OeAYnhTiaQpgnMieZe+jfITqG7A4MQB5+5ZLiwCseedSqAmtgScKMnizcRY MxSGfK0/GinxnLiKll8C3Mn/vm729ymL0W6uMQ73L2mD7EeWuiZjLH40LoEjNDmjivLa9DKj1yk lCALlpnUgtN9tNoSWeZ/9gfCbFmOhNvuokavU+lT3In4KNrzVtiM2SXVLN5AFp3UsjAeuDVQHsa WrKSxluXU5bI970YOrWJrkUTtdNB4D75oLT1j6bmIUVnDv1mwwrYsic3ZyYDPljW9Y9nGx6OhPg Qsp4YCuy6CXFUNrPthhQFjzKMzdcy4Lv3HE X-Received: by 2002:a05:6820:2216:b0:679:a463:c933 with SMTP id 006d021491bc7-679c4513d06mr5055369eaf.71.1771904247267; Mon, 23 Feb 2026 19:37:27 -0800 (PST) Received: from ?IPV6:2600:1700:8952:80:e08a:9894:2f23:ace1? ([2600:1700:8952:80:e08a:9894:2f23:ace1]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-679c565728esm7507583eaf.8.2026.02.23.19.37.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Feb 2026 19:37:25 -0800 (PST) Message-ID: <043bf2c3-d39a-4592-be83-bf68eb1befcf@gmail.com> Date: Mon, 23 Feb 2026 21:36:31 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Add Windows support for backtrace_functions (MSVC only) To: =?UTF-8?Q?=C3=81lvaro_Herrera?= Cc: Euler Taveira , Jakub Wartak , Michael Paquier , pgsql-hackers References: <202602232201.2d5ez5tbrkg2@alvherre.pgsql> Content-Language: en-US From: Bryan Green In-Reply-To: <202602232201.2d5ez5tbrkg2@alvherre.pgsql> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/23/2026 4:07 PM, Álvaro Herrera wrote: > On 2026-Feb-23, Bryan Green wrote: > >> I have implemented DuplicateHandle and closed the handle in the >> appropriate places. I also reset backtrace_process to NULL if >> SymInitialize() fails. Patch is attached. > > Hmm, should then backtrace_cleanup() cope with the case where it's NULL? > > Also, I wonder what happens if one "backtraceable" error occurs, and we > fail to SymInitialize(), then another backtraceable error occurs. > Should we do the DuplicateHandle()+SymInitialize() dance again, or > should we just give up? The current implementation does the former, I > think; but the latter is also easily achievable by setting > backtrace_symbols_initialized to true and leaving backtrace_process as > NULL; then this case can be detected specifically in set_backtrace() and > treated as a case where we just return NULL before attempting anything > else. > backtrace_cleanup() only cleans up on process exit-- so, it is almost a style choice. If we are going to close the handle in cleanup we should probably stay consistent and reset backtrace_process to null as well. If SymInitialize() fails...I can not imagine it ever succeeding after that. It is an expensive call...a process generating errors shouldn't be burning time retrying a failing system call on every error. I agree with not retrying. I'll put together another patch with those changes. -- Bryan Green EDB: https://www.enterprisedb.com