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 1sbrCO-001w35-Qc for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 00:40:12 +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 1sbrCN-00AuEe-4Z for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 00:40:11 +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 1sbrCM-00AuEW-LA for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 00:40:10 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbrCJ-003clQ-Kg for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 00:40:09 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52f04150796so442501e87.3 for ; Wed, 07 Aug 2024 17:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723077606; x=1723682406; 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=KVffdlTJZ3lzlgLTvuM2aa1bdlmTs8q7uGgA4TsfDuc=; b=RINdMs2SPMrj+vuYf95k+T/nnuVaeAYqS5IN+sdKzs0qdsRJnT94hPzup+EDc0Waqk x7PMRGQP6x7/Fanj9DJxGEM/AERmSUX7/d65UGnTxzeu9WrYw9m/Tn958chmZQ7Z51gs UK2YxBfXVR4eselJ6/LZ2t1G3wJBBQdYj9JbJJuyNJSIH6e1pgO2MzrYcdap2380Iz75 ePXm2xUXyPDHwfOx/rn5GNyImNbJ4u7NYW7dLElvQXyXpbDwJQvMX8SVZEng5L72tV+f yD6RAubmN/kZmvHBJEwzBGl1Ds+hFtF9yHBT0MVR54irBoAZvc/RWHRq0VEoQulBwWtF dgRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723077606; x=1723682406; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KVffdlTJZ3lzlgLTvuM2aa1bdlmTs8q7uGgA4TsfDuc=; b=GxUVZCWxtnCCzUPWvOrlHZtTySAWj0YPV04NfDTqNEDij1huGmtdDYEUkj+ECoLRC7 L9w8qBcsXA1haKZ3LMXssHqCRei6xN6M+aksDoNqHM6hdIxR49OHxFebCbi4oNqYVND1 p0TsIImnAqxxaHVEd+gV1RFqEYRhEl7PPY9sAUDpni6cURxEay+m+9IMOSj8aJkeBRcM 2BOZxaWM0WDANcHeUav7bZKCBK+JantUjjq3pqnueSTXot+AmAhE47q2/v2A2IFPZXqp 0zDn8jWgk8ShkqpSbG8qD2hQ9/vnDkSv3FCD7Ir3HeM5MaMDcsLFemZ5pmeqAWXdcbU9 EMXg== X-Forwarded-Encrypted: i=1; AJvYcCU+Gz1H7Ylhf4rDN7SiiHk7dtYsMvYcryvyXk9VavM+AOda7aaAeMYqf3QDsCzSFS9HlKbebHOLzmz5WwY+BgTIp/E93ghfJEP+WLkczn5kb9XD X-Gm-Message-State: AOJu0Yy37lNDVIikPz+bnCH9sT311PzDBtPt9KBV/ydyHLPygO+xT0f5 ukT3ZR6jqgg7RZb4a2gglit0/EDQsBYVpmIZe4qj9IEAuNSbxB/fJqF59h4MmGm2gsm4LhCbfJh g406he3jHb69e4d0jy/+M6X3e2A0= X-Google-Smtp-Source: AGHT+IEWAJ679Qd4PR5Ut0d0WY9N0lzuiE+qGOGakaELbtot2B2mpQsNPtqzwc3OB5/QUcD3tFY/AmZuDjrjX1nhe0U= X-Received: by 2002:a05:6512:2396:b0:52e:8475:7c2a with SMTP id 2adb3069b0e04-530e582d702mr147187e87.15.1723077605530; Wed, 07 Aug 2024 17:40:05 -0700 (PDT) MIME-Version: 1.0 References: <80c9b0ea-c874-40ad-a006-fb1eb37464c2@aklaver.com> <44b44ece-dce6-4b4f-b751-8787a5a071e0@aklaver.com> In-Reply-To: From: Thomas Munro Date: Thu, 8 Aug 2024 12:41:29 +1200 Message-ID: Subject: Re: Windows installation problem at post-install step To: Sandeep Thakkar Cc: =?UTF-8?B?RXJ0YW4gS8O8w6fDvGtvZ2x1?= , Adrian Klaver , pgsql-general@lists.postgresql.org, Manika Singhal 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 Thanks. The log didn't offer any more clues, and my colleague David R has Windows and knows how to work its debugger so we sat down together and chased this down (thanks David!). 1. It is indeed calling abort(), but it's not a PANIC or Assert() in PostgreSQL, it's an assertion inside Windows' own setlocale(): minkernel\crts\ucrt\src\appcrt\convert\mbstowcs.cpp(245) : Assertion failed: (pwcs =3D=3D nullptr && sizeInWords =3D=3D 0) || (pwcs !=3D nullptr= && sizeInWords > 0) 2. It is indeed confused about the encoding of the string "Turkish_T=C3=BCrkiye.1254" itself, and works fine if you use "tr-TR". 3. It doesn't happen on 15, because 16 added a key ingredient: commit bf03cfd162176d543da79f9398131abc251ddbb9 Author: Peter Eisentraut Date: Tue Jan 3 14:21:40 2023 +0100 Windows support in pg_import_system_collations That causes it to spin through a bunch of system locales and switch to them, and the first one is "aa". After it calls: setlocale(2, "aa"); ... then the next call to restore the previous locale is something like: setlocale(2, "Turkish_T\252rkiye.1254"); (That \252 =3D=3D 0xfc probably depends on your system's default encoding.) It doesn't like that name anymore, and aborts. A minimal program with just those two lines shows that. It appears that after switching to "aa", it interprets the string passed to the next call to setlocale() as some other encoding (probably UTF-8, I dunno). I don't know why it doesn't fail and return NULL, but there is a more general point that it's a bit bonkers to use non-ASCII byte sequences in the library calls that are used to control how non-ASCII byte sequences are interpreted. Maybe it can be done if you're careful, but in particular a naive save-and-restore sequence just won't work. I guess a save-and-restore done with wsetlocale() could fix that. But I decline to work on that, we need less Windows kludgery in the tree, not more. I think a better answer is "don't do that". Really, we *have* to chase all these non-BCP-47 locales out of the installer (I hope you can work on that?), out of PostgreSQL (testers wanted[1]), and out of the world's existing clusters (maybe with Dave's pg_upgrade idea, someone would need to write a patch, or maybe someone could write a stand-alone locale migration program that just connects to a cluster and (using some authoritative source, that's the key bit to research) and replaces bad old names with nice new ones). [1] https://www.postgresql.org/message-id/flat/CA+hUKGJ=3DXThErgAQRoqfCy1bK= PxXVuF0=3D2zDbB+SxDs59pv7Fw@mail.gmail.com