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 1sEAMo-00HaQ5-D8 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jun 2024 16:17:03 +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 1sEAMl-00BPbe-TO for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jun 2024 16:16:59 +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.94.2) (envelope-from ) id 1sEAMk-00BPbW-Ol for pgsql-hackers@lists.postgresql.org; Mon, 03 Jun 2024 16:16:59 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sEAMi-0029Yl-0J for pgsql-hackers@lists.postgresql.org; Mon, 03 Jun 2024 16:16:58 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4VtJl8477Cz9sV4; Mon, 3 Jun 2024 18:16:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1717431412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8cGK7iG7LUfaXKe8MdqIDRz8SWp8CNaA0hQ6BxQZ84o=; b=Fxg0I+XD9bPzQD9dkV64+7jBvyj2m2MU8Yca9UMbEB4blabN5oaiZethPlAc7iBgn7H+q4 dh/XhD/RGw0c/Rx9VaQ8ZEQCGg5dLYm/HypDR6b/OPrdAvp6Knhku6Nko5tI9RzFY33s2K LJFgNdqt5p/DpkXMybywBTDDcOpyldGba3QCsHSerfFXVzFwvEfKLrRLJrv+v6UT3kR7nx Xks5y9nfECuLrBorNrAOsQvM+rArJoUtF9Ad9jduu6YsCx4r+XeFEDQjQqIZgEbT5KJbkM cPUYCngE8DHSJIL9sm2vFCSU08gl+u/O4ccXLkreH5NkL+jvpN6yHjYVHXMBZw== Date: Mon, 3 Jun 2024 18:16:48 +0200 From: Erik Wienhold To: Tom Lane Cc: Pierre Forstmann , "a.kozhemyakin" , pgsql-hackers@lists.postgresql.org Subject: Re: pltcl crashes due to a syntax error Message-ID: <309214c5-d4da-4e00-938d-0e35990e564c@ewie.name> References: <6a2a1c40-2b2c-4a33-8b72-243c0766fcda@postgrespro.ru> <5af13487-7722-4bdd-bad3-939598c8dd4e@ewie.name> <2365308.1717366548@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2365308.1717366548@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-06-03 00:15 +0200, Tom Lane wrote: > The new bit of information that this bug report provides is that it's > possible to get a TCL_ERROR result without Tcl having set errorInfo. > That seems a tad odd, and it must happen only in weird corner cases, > else we'd have heard of this decades ago. Not sure if it's worth > trying to characterize those cases further, however. ISTM that errorInfo is set automatically only during script evaluation. The Tcl_AddErrorInfo manpage says: "The -errorinfo option value is gradually built up as an error unwinds through the nested operations. Each time an error code is returned to Tcl_Eval, or any of the routines that performs script evaluation, the procedure Tcl_AddErrorInfo is called to add additional text to the -errorinfo value describing the command that was being executed when the error occurred. By the time the error has been passed all the way back to the application, it will contain a complete trace of the activity in progress when the error occurred." Tcl 8.4 basically uses the same wording. Except for the reported case, we only call throw_tcl_error in three places, all after checking the return code from Tcl_EvalObjEx. And this one Tcl_ListObjGetElements instance is not called during script evaluation. > > Or just do away with throw_tcl_error and call ereport directly. > > I'd say this adds to the importance of having throw_tcl_error, > because now it's even more complex than before, and there are > multiple call sites. I agree to have some uniform error handling. But from the current usage it looks as if throw_tcl_error is tied to Tcl_EvalObjEx. -- Erik