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 1wB86J-000lT0-0d for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Apr 2026 09:24: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 1wB86H-00AwNH-11 for pgsql-bugs@arkaria.postgresql.org; Fri, 10 Apr 2026 09:24:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wB86H-00AwN8-0C for pgsql-bugs@lists.postgresql.org; Fri, 10 Apr 2026 09:24:29 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wB86G-00000000KTa-01rG for pgsql-bugs@lists.postgresql.org; Fri, 10 Apr 2026 09:24:29 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-685013eb590so1128381eaf.1 for ; Fri, 10 Apr 2026 02:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775813066; cv=none; d=google.com; s=arc-20240605; b=hO2Jvv9ttbIUlMlJ+NVi9Y7nFxt1zF8wR1ApJ9rlWfejqS3VIs9jD0Hyy8R2FnbMZZ ehH9lK9eF1mXpyY2vhOXs0IBSEBT+37RN/hgJ3wntSBRD05pUUkoqCuCpKyLxov+/AOy A23IDyn63lZCTBLgUUttB9DRnkyyspUpM/Q0mLq+yOEVSNVQ++QDCqkUq0KHBfTfB4Dd R19rANLVr0gSliBAp6sxn/eakaBh8LQD6Vakj3JV3cwjGcwX9MO+Ns/YQ6c7Dx6ZCJs7 CU/Ix0vxa2dHZnFVqWCpS2s64E31Q8lP3thGZvdUiWLUPt8kxv9IB9XkQaP3HGERRd5r +aVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kWq7d531K5eRIKu9snaVpDEER4Z+8p+nBulF16u/lIM=; fh=LP7w9+kmiC8z13HfytA+fzKVpm+sbLL3nkQZr76gUqY=; b=YjZfq1jS/kClgNBTa5LTuQxI8dxE9eknRmFnUdUVY3W6G8TFsQKh3OHqMRnsX91Mjh b68loTusSkpmasH830DftbkVmcpZBgB+OEIZ/Fxz40YIf8zXrG4X9YFhmLfisVv9FIKm AKlpgi1PhnvHag/bzXpsFo1mWbxT+iH95rDPimsCeGlvAYT8ab0qJZo6c1zIMvKfuxGr mcLKlErs1Rfq3RiWSQ5qS9KASqHNkFBfpmztRC9Jl+pE9azHMaq2WMG/WADgnsCGRYxz bRETiQ/ajt/ormvwfRPOIvb/Tgz30hwx0lBDc5x+viME/+3LxF5YwhcUMQhXpurZbceT bzPw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775813066; x=1776417866; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kWq7d531K5eRIKu9snaVpDEER4Z+8p+nBulF16u/lIM=; b=W9knp9gsK+R4B4QHNFKVwBWYLWLJCx6U6YvKtLFjQ7uAfGNY21b4sdoiDPi/fPlotd q6mRX2nFoOYi1OPFxO/V3VSz8fYNaitw8P3Vetv+cAUbfTixSI7K24+3QzRxN2dDEDjb 0Pjq97gIpsmaN5uPZGMleaTSQ8TJddz5lwWtTTI3YfJlQext1eVwKOsuUgZnFV3qleNP WNdkUqgLcr9Gu4sx7LEpIqZNd0t6EKV019tD15o3GN4dRidmG2Xp+6vwC4MpHqBegIC7 vHwv+Asmktaop/+00gsqI8r98F9g56+KzB6vkg+EnGoXuIAWHtMKssCjkqseyNEhEYhL iB8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775813066; x=1776417866; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kWq7d531K5eRIKu9snaVpDEER4Z+8p+nBulF16u/lIM=; b=LiXoZUVym6ODUX4ABG0RTJxlPAoCeFXRouvqO6PhmqhnqyohQuQHoPXHT68eLHWl1A qK3pLD+pulgZqkTvaw4rPgCmIxTAwj0DzWS9zgOtmyP68zm8DVgbYBaRBB1tDZ1Va+4R SqcWl+Wqv1VKpQJicjzA0w+Pc2SGlGj/NM7Y6w7uA9t/DYHIMrAOxzswxaiBLh4HJ5AC 1lsR4X/h0GpFQqWzVDpI00rBRG5a9m0+0DJLx9nuXnQED3P7Xt9dE7BGH8mq6HqFlgH6 Fcuv1ESDjtD2v4XO6rmV+yfvMMKHyfk8rf/PdpRcZWoG9JgykG6idebCllVCe3tEzAPU +jvg== X-Forwarded-Encrypted: i=1; AJvYcCVPi8bGoWh3kOk7LmRdFdLR54HarI2DrI/BHBMkGyOgypxO5iFturRklztGKs2NANG9oMCpgfoMrPE1@lists.postgresql.org X-Gm-Message-State: AOJu0Yxva4NUedGqYF/ZLBcfvraA8G9Ym9L5tjdi6NcMvZP1fbfcW41K f+3Fl/qucuGoS8ISsddRkZ6b14Pmf6beum3nIO6b5auIvXbsN2WYqjEF59rqCO35mloVyDQXfzH 0376icBsL8C8k/qBb38BnQVShdLe3LsU= X-Gm-Gg: AeBDieuga6KzRWH+y+wJ+BqLiDRtA77Bb75qINrwEUH+wEdRkj1T8WKbXLdxKnQLbdj h36kPxbsBVqF4h1/TWjLvhP05RkqVAuB273dZHBESFrRWd54aiR0u0Z7l5ppexc8eUTsekSzpES sdqEavDfHvTmW9KUZaHHzCubUjk+sVnHdqlPTxP6zBOzXzcE2dLPt6CA88Hov59R0rbu0FJA7nS 7mQeDG/0c7Nap8sO0gdIw7eTnR4JyI0fmX9Caq29+3ddhj1GA3yfZrqxkc1CR/mF6XZQPS4VEY2 6qyUoDP6lQ== X-Received: by 2002:a05:6820:1620:b0:67e:432a:9c9 with SMTP id 006d021491bc7-68bf8cc632dmr879799eaf.31.1775813065789; Fri, 10 Apr 2026 02:24:25 -0700 (PDT) MIME-Version: 1.0 References: <19405-1ecf025dda171555@postgresql.org> In-Reply-To: From: Richard Guo Date: Fri, 10 Apr 2026 18:24:14 +0900 X-Gm-Features: AQROBzAbKwuaukbHbQlG8HOaHTzKSgY0f-58H6ACD_WEFbcJxJZS6FGEeFqrtiU Message-ID: Subject: Re: BUG #19405: Assertion in eval_windowaggregates() fails due to integer overflow To: Tender Wang Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 8, 2026 at 6:42=E2=80=AFPM Richard Guo = wrote: > Here is the updated patch. I've added test cases for GROUPS mode with > an overflow-inducing offset. These don't seem to produce visibly > wrong results without the patch. I believe that is because the > incremental nature of group pointer advancement happens to mask the > misbehavior. But I think they are still worth having since signed > integer overflow is undefined behavior in C. > > Regarding performance, I don't think this should be a concern. > pg_add_s64_overflow compiles down to a native add+jo sequence on > platforms with __builtin_add_overflow, and falls back to a couple of > inlined comparisons on others. Either way, the cost seems negligible > next to the per-row tuple store and aggregation work these functions > already do. I forgot to mention that I've committed and back-patched this fix. - Richard