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 1rVvmv-002CG8-N0 for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2024 15:49:10 +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 1rVvmu-00ECit-35 for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2024 15:49:08 +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 1rVvmt-00ECil-Qt for pgsql-bugs@lists.postgresql.org; Fri, 02 Feb 2024 15:49:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVvmn-004j9d-0p for pgsql-bugs@lists.postgresql.org; Fri, 02 Feb 2024 15:49:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 412FmurC3154182; Fri, 2 Feb 2024 10:48:57 -0500 From: Tom Lane To: Christian Maurer cc: pgsql-bugs@lists.postgresql.org Subject: Re: Aw: BUG #18312: libpq: PQsetdbLogin() not thread-safe In-reply-to: References: <18312-bbbabc8113592b78@postgresql.org> Comments: In-reply-to Christian Maurer message dated "Fri, 02 Feb 2024 11:21:46 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3154180.1706888936.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 02 Feb 2024 10:48:56 -0500 Message-ID: <3154181.1706888936@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Christian Maurer writes: > I managed to capture a stack trace for the crash via WinDbg: > =C2=A0 > Frame Index=C2=A0=C2=A0 =C2=A0 =C2=A0Call Site=C2=A0=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 Child-SP=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0Return A= ddress > [0x0] =C2=A0 =C2=A0 =C2=A0 =C2=A0 ntdll!NtTerminateProcess+0x14 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fdf88 =C2=A0 0x7fffce3cda98 > [0x1] =C2=A0 =C2=A0 =C2=A0 =C2=A0 ntdll!RtlExitUserProcess+0xb8 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fdf90 =C2=A0 0x7fffcd99e82b > [0x2] =C2=A0 =C2=A0 =C2=A0 =C2=A0 KERNEL32!ExitProcessImplementation+0xb= =C2=A0 0x18aa9fdfc0 =C2=A0 0x7fffcd42a155 > [0x3] =C2=A0 =C2=A0 =C2=A0 =C2=A0 msvcrt!_crtExitProcess+0x15 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fdff0 =C2=A0 0x7fffcd42a7c5 > [0x4] =C2=A0 =C2=A0 =C2=A0 =C2=A0 msvcrt!doexit+0x171 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fe020 =C2=A0= 0x7fffcd41f26d > [0x5] =C2=A0 =C2=A0 =C2=A0 =C2=A0 msvcrt!abort+0x8d =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fe09= 0 =C2=A0 0x68281886 > [0x6] =C2=A0 =C2=A0 =C2=A0 =C2=A0 libintl_9!libintl_bindtextdomain+0x56 = =C2=A0 =C2=A00x18aa9fe640 =C2=A0 0x7fff7dcd2e93 > [0x7] =C2=A0 =C2=A0 =C2=A0 =C2=A0 LIBPQ!PQenv2encoding+0x1193 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x18aa9fe670 =C2=A0 0x7fff7dcd2c9e Hm, so it's bindtextdomain() that is aborting. Back at [1] I wondered whether we needed to introduce a critical section to prevent multiple threads from calling that concurrently, even though its docs allege you shouldn't have to. Perhaps it's thread-safe except on Windows? regards, tom lane [1] https://www.postgresql.org/message-id/flat/CAE7q7Eit4Eq2%3Dbxce%3DFm8H= AStECjaXUE%3DWBQc-sDDcgJQ7s7eg%40mail.gmail.com