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.94.2) (envelope-from ) id 1tqavo-007SXE-Qy for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 16:52:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tqavn-00Bnqp-9u for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Mar 2025 16:52:15 +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.94.2) (envelope-from ) id 1tqavn-00Bnqh-0I for pgsql-hackers@lists.postgresql.org; Fri, 07 Mar 2025 16:52:15 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tqavl-001Wjs-0P for pgsql-hackers@postgresql.org; Fri, 07 Mar 2025 16:52:14 +0000 Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-3d439f01698so6478365ab.1 for ; Fri, 07 Mar 2025 08:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741366332; x=1741971132; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AwnrWonhkvLFMxXZqgEKHc05RDxV1OGYW2M2SLNAEWc=; b=C0RMEDPFXjaaIbZ0T0+yO05wMW1WZHBHMxIgMqraqDXRSHL8A+8JdI4qsSIpLCyIM6 bHPFD/FmWhc9sVEiFBJ9HlJU+u/qvoN0AvijmshP3NySosO2I+XjwtPg2auvRyOzA9+2 RL2VeOTJDR60fSZkVHLR1us8E9m3kEE95rcKVQqAVZnor69SJakd2MXUzBqpvhpVTE0w nuf2gZ8v4a+j9gPrO3/TRukiH4qyXSX9/gNHN/olWe02oYmeQsis70vlRwKtPlI/QKsw XsGUJF5Rh2RntVMsQQT7TVfNCEwIb7I5VLAQ0DD+rekp63X/tFOkyUZMpwaFHZNSTWUm RgUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741366332; x=1741971132; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AwnrWonhkvLFMxXZqgEKHc05RDxV1OGYW2M2SLNAEWc=; b=l6TF7MENuEeOt4LiAeIqkpIIaKUfiqgRWR6o8QvMb6LTbiaqkwSgBaAIUcqEJM/XSN bi8CPhOdzV5OWE3MQ8ap6wDMoqn24n1nCpuqwzh6LuHp3WdcanEvpYwFqALpDhXNZzjh nYfjCG+4L4QZJRIFItqc4RLQZpVOYmKqoEs5x5cSARfFEFjnxWxN4BPn2cwgBp4jKhgV NbY79kNJ0BswLyot2Ujm64FAr+FXAspuqLMUpFPmLD75q4XdQLMoMS/QIFiU8FuYPa1U odEtvqnCBz+H5iI2SbQxPzG01W8Gnyi80GjXbkIF2K5NuPC8sxvJyNu0TyWaKWaZ7Q4z SBAQ== X-Forwarded-Encrypted: i=1; AJvYcCVviVtX6xNu8uR+MfSGq5OvbaHFNSvP/weLlWJaUrmYuYHdPRCheIWirr1xtVyYLwm68w+03QWbkRuyQh55@postgresql.org X-Gm-Message-State: AOJu0YxZiMiFGIMjmdsUh84UMJunutQ6CCwckye4cjePAxcxinbQoU/7 L8osUlqv4eo0SKqziRCXqRFBj0U4gYbuYOfX/gN7x4K1aKl4Uz0t X-Gm-Gg: ASbGncsjo5zJl9IfqOvkpfpUUA5wx3+oi5p5lltPngcDG5vC621JBlXyr846d/6l+PN SMq5WLZIi2PYgSxlwRQVQ9OOylq7GTSY9CiPdTqb88Pc0ugKi66iqjR5wWtIu+q4JC2Lya6c+Hr CBIcZQHell4fQvAluI6b7gX3ujzTdN7IOqiuBxUkiLJGdccef/PLynEGuj19hP3bDjC7pkX5F2Q MEim7kC+T9QNYdTFn8Diug4xH2KHCV8ArAXb+Z4kau10p7zOIIVlVFVifmPS6Y93KRx59nqDKqS U/y/RiMZC4Gn5JOo6b10kUBkUh2CM7S5rKErhoyJJ7DG96pc0+xNrpp+tTrBvCzG2LXmvhEE+TP Pjr5yvDOY0fnS6E/Hur7/Kyrb94BhN51LQX88SZVu X-Google-Smtp-Source: AGHT+IF3wApQ473L8JXjO0uTPddyyIfShCiIcNy08pRlTav9x8UpdaIayjtO55djTDqxIzST06lpCA== X-Received: by 2002:a92:d404:0:b0:3d4:2306:fbb6 with SMTP id e9e14a558f8ab-3d44af3e8b6mr2634415ab.10.1741366332441; Fri, 07 Mar 2025 08:52:12 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4f20a06c7cesm1004263173.138.2025.03.07.08.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 08:52:11 -0800 (PST) Date: Fri, 7 Mar 2025 10:52:10 -0600 From: Nathan Bossart To: Andres Freund Cc: Tomas Vondra , PostgreSQL Hackers Subject: Re: strange valgrind reports about wrapper_handler on 64-bit arm Message-ID: References: <77dxan5ga3rjxjbnm2vtljntbcpab3wov2zlcdukw75a2qojmu@3mbkzfpv54sd> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1IwYB9lJQVGT1KOB" Content-Disposition: inline In-Reply-To: <77dxan5ga3rjxjbnm2vtljntbcpab3wov2zlcdukw75a2qojmu@3mbkzfpv54sd> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --1IwYB9lJQVGT1KOB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 07, 2025 at 11:41:38AM -0500, Andres Freund wrote: > On 2025-03-07 10:36:35 -0600, Nathan Bossart wrote: >> On Fri, Mar 07, 2025 at 11:32:28AM -0500, Andres Freund wrote: >> > Is it possible that the signal number we're getting called for is above >> > PG_NSIG? That'd explain why the source value is something fairly random? >> > >> > ISTM that we should add an Assert() to wrapper_handler() that ensures that the >> > signal arg is below PG_NSIG. >> >> We have such an assertion in pqsignal() before we install wrapper_handler >> for anything. Is there another way it could be getting called with a >> different signo? > > Who the hell knows :). > > One potential way would be that we got SIGNAL_ARGS wrong for the platform and > are interpreting some random thing as the signal number. Or something went > wrong in the windows signal emulation code. Or ... > > It seems cheap insurance to add it both places. Good enough for me. I'll commit/back-patch to v17 the attached soon. -- nathan --1IwYB9lJQVGT1KOB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="assert.patch" diff --git a/src/port/pqsignal.c b/src/port/pqsignal.c index 5dd8b76bae8..79b50486175 100644 --- a/src/port/pqsignal.c +++ b/src/port/pqsignal.c @@ -87,6 +87,8 @@ wrapper_handler(SIGNAL_ARGS) { int save_errno = errno; + Assert(postgres_signal_arg < PG_NSIG); + #ifndef FRONTEND /* --1IwYB9lJQVGT1KOB--