Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZMpRq-0004Gi-JR for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Aug 2015 03:32:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZMpRq-0000EL-5D for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Aug 2015 03:32:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZMpRD-0007xw-Rm for pgsql-bugs@postgresql.org; Wed, 05 Aug 2015 03:32:19 +0000 Received: from mail-pd0-x234.google.com ([2607:f8b0:400e:c02::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZMpRB-0002WR-0f for pgsql-bugs@postgresql.org; Wed, 05 Aug 2015 03:32:19 +0000 Received: by pdber20 with SMTP id er20so12491790pdb.1 for ; Tue, 04 Aug 2015 20:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=WU/wLu0vH9PuyHrE+SitAdFG3+ZgFlcERD6lChBQ2ns=; b=cJTRs1c6DqSChs/9U1uwnk/WmfpNUknuvp61YI3VSNBc6Gh47B2FxfX/jtL0Ls/N3R zxbphgY3wxbrTvQ97AgFWZFx/76YBWIywXP36X5swyE1bwW0U7BcnWCCHgIWnSxSleg+ elUmpDm1avedJh685A3r0xOI7TODOaQwGqunE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=WU/wLu0vH9PuyHrE+SitAdFG3+ZgFlcERD6lChBQ2ns=; b=JJp1R5KcrgT8nwgh81PI/MBKnYAvAHJLuRUwZWyCbPPeEHlA/gizG/tpn+LIcrY3U7 K483B+PSnslnqSCKSuw098k2jSYYFrpMxkpXYnXrKaKT2piDaXExeAI6A3X0IR7QAK8e uLhclqyW5pi5SxTmn/ADy3mHonYBHj9LDCeaUVwL6/I8zpBb2s5Cc+SVzyLlxdut2q3f 39YjFsrmQ/o+8mtVlPW899K5BSBDOq9vSRsTnV7HO/HCvu+1VobqNovMawXcbrhtkRo1 n6mSS461ll3ZcB1uVWfs4PNWFdeifyrOqj1vs33XLRO/vdcLltxBT0og6vLO0nvhA1e6 nRHQ== X-Gm-Message-State: ALoCoQnne+t6TaJVvqFvR9h0aC/Fjzz9QZ/MztKwTVKmrLFWUa4d8d+hkNE47O3yH39RfnWgt3fE X-Received: by 10.70.118.5 with SMTP id ki5mr15205738pdb.6.1438745534509; Tue, 04 Aug 2015 20:32:14 -0700 (PDT) Received: from tornado.leadboat.com (c-98-248-47-228.hsd1.ca.comcast.net. [98.248.47.228]) by smtp.gmail.com with ESMTPSA id ex13sm925696pac.17.2015.08.04.20.32.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 04 Aug 2015 20:32:13 -0700 (PDT) Date: Tue, 4 Aug 2015 23:32:11 -0400 From: Noah Misch To: Dmitri.Bourlatchkov@software.dell.com Cc: pgsql-bugs@postgresql.org, tgl@sss.pgh.pa.us Subject: Re: BUG #13427: postgres.exe fails to start on Korean Windows Server 2008: cannot perform encoding conversion outsid Message-ID: <20150805033211.GA1768970@tornado.leadboat.com> References: <20150610143235.2796.52303@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150610143235.2796.52303@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Wed, Jun 10, 2015 at 02:32:35PM +0000, Dmitri.Bourlatchkov@software.dell.com wrote: > PostgreSQL version: 9.4.3 > Operating system: Windows Server 2008 (Korean) > 0. Log in as a local Administrator into a Korean version of the Windows > Server 2008 > 1. Install PostgreSQL 9.4.3 using the Windows .exe installer from > EnterpriseDB > 2. Open cmd.exe shell > 3. cd to potgresql/bin directory > 4. Run postgresql.exe (no args) > 5. Observe the following error message: > > ---- > FATAL: XX000: cannot perform encoding conversion outside a transaction > LOCATION: pg_do_encoding_conversion, src\backend\utils\mb\mbutils.c:360 > ---- > > A similar message shows up when using pg_ctl.exe to start PostgreSQL. Thanks for this report. One can reproduce this without Korean-specific OS configuration by setting LC_CTYPE=Korean in the environment and then, as you say, running postgres without arguments. Stack trace: postgres.exe!errfinish(int dummy, ...) Line 412 postgres.exe!elog_finish(int elevel, const char * fmt, ...) Line 1376 postgres.exe!pg_do_encoding_conversion(unsigned char * src, int len, int src_encoding, int dest_encoding) Line 362 postgres.exe!pgwin32_message_to_UTF16(const char * str, int len, int * utf16len) Line 1081 postgres.exe!write_console(const char * line, int len) Line 2111 postgres.exe!write_stderr(const char * fmt, ...) Line 3592 postgres.exe!SelectConfigFiles(const char * userDoption, const char * progname) Line 4297 postgres.exe!PostmasterMain(int argc, char * * argv) Line 802 Commit 49c817e is the proximate cause. On my Windows Server 2008 system, Korean is the only locale affected. It's affected because pg_enc2name_tbl lacks a UHC <-> CP949 mapping. I'll double check, but adding that mapping should fix this particular test case. That leaves other ways of reaching this error. I think e.g. an LC_CTYPE=C, ENCODING=LATIN9 database will still take this path. Any EmitErrorReport() can run pgwin32_message_to_UTF16(), and those have plenty of ways to run outside a transaction. I am inclined to restore the 9.3 and earlier semantics by having pgwin32_message_to_UTF16() proceed, when outside a transaction, as though the string is already UTF8. A robust fix would be to cache enough information about the message encoding to convert outside a transaction, exactly the way we protect database<->client encoding conversions. That feels more like a master-only change, though it's a borderline case. > Trouble-shooting attempted: > 1. Run set LC_CTYPE=C > 2. Run postgresql.exe (no args) > 3. The following expected error shows up: > > ---- > Execution of PostgreSQL by a user with administrative permissions is not > permitted. > The server must be started under an unprivileged user ID to prevent > possible system security compromises. See the documentation for > more information on how to properly start the server. > ---- > > Note: PostgreSQL _is_ able to run as a Windows Service without any > environment modifications. > > Note: If the LC_CTYPE=C env. variable is set, PosgreSQL can also be started > successfully via pg_ctl (under the Administrator user). That looks normal. pg_ctl has special code in CreateRestrictedProcess() to drop administrative privileges. To run raw postgres without pg_ctl, use an unprivileged account or drop privileges similarly in your own wrapper. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs