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 1sEFY1-000RE1-LE for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jun 2024 21:48:59 +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 1sEFY1-00D4u3-KS for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jun 2024 21:48:57 +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 1sEFY0-00D4tv-9q for pgsql-hackers@lists.postgresql.org; Mon, 03 Jun 2024 21:48:57 +0000 Received: from mout-u-107.mailbox.org ([2001:67c:2050:101:465::107]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sEFXx-002BuM-L0 for pgsql-hackers@lists.postgresql.org; Mon, 03 Jun 2024 21:48:55 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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-107.mailbox.org (Postfix) with ESMTPS id 4VtS6B28Nqz9s37; Mon, 3 Jun 2024 23:48:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1717451330; 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=OjkpAsijRZAwgAZo/is3ENs+wK/6Ay9loyQaFazBXJM=; b=vFxCN8uTKUttWIYQJ65+m83BT/MX8zdX6CzUFEAOem9231QMEwgUT1xQVFdx1YHus2r2SJ +74gVktFuFp9NXqwJPmolx+SB3QgJlSW9pok4umA0FuY1J/jvYPv04FdFjSeWIvA9vi+9u RZHmZBkgsfSVjqK4AKdmHXk2N5TcMy7wuHzfp/JWU2S72PJ7ay9kK3gr1sCzny1kEFLcnZ PlMMqpRAtWKjFjrLZB9sdPw4bwsT31YCVBlwBierYMVX/GxmvSeUFNxfKRFtOTRbk3rBjc acMXgyKZo1R4QAjbX0Hh4A0DYry/gOkzPL8vmF0si7N+AYVRO5XQeamRCV36nQ== Date: Mon, 3 Jun 2024 23:48:47 +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: References: <6a2a1c40-2b2c-4a33-8b72-243c0766fcda@postgrespro.ru> <5af13487-7722-4bdd-bad3-939598c8dd4e@ewie.name> <2365308.1717366548@sss.pgh.pa.us> <309214c5-d4da-4e00-938d-0e35990e564c@ewie.name> <73249.1717433869@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73249.1717433869@sss.pgh.pa.us> X-Rspamd-Queue-Id: 4VtS6B28Nqz9s37 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-06-03 18:57 +0200, Tom Lane wrote: > Erik Wienhold writes: > > 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. > > Yeah, I've just come to the same conclusion. Changing throw_tcl_error > to ignore errorInfo if it's unset would be wrong, because that implies > that the function we called doesn't fill errorInfo. I found by > testing that it's actually possible that errorInfo contains leftover > text from a previous error (that might not even have been in the same > function), resulting in completely confusing/misleading output. > > So your thought that we should just not use throw_tcl_error here > was correct, and a minimal fix could look like the attached. LGTM. > Also, compile_pltcl_function contains a Tcl_EvalEx() call that > presumably could use throw_tcl_error, except it wants to add "could > not create internal procedure" which would require some refactoring. > As far as I can tell that error case is not reproducibly reachable, > as it'd require OOM or some other problem inside Tcl, so (a) it's > probably not worth troubling over and (b) changing it is a bit scary > for lack of ability to test. I'm inclined to leave that alone too. Agree. > The other thing I noticed while looking at this is that the error text > for the other Tcl_ListObjGetElements() call seems a bit confusingly > worded: "could not split return value from trigger: %s". You could > easily read that as suggesting that the return value is somehow > attached to the trigger and has to be separated from it. I'm > tempted to suggest rephrasing it to be parallel to the new error > I added: "could not parse trigger return value: %s". But I didn't > do that below. Yeah, I'd fix that trigger error text as well to bring both in line. -- Erik