From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#44173: 28.0.50; gdb-mi mangles strings with octal escapes Date: Fri, 23 Oct 2020 19:31:47 +0200 Message-ID: <865DFE77-16F6-4F20-8238-76E6A09801C8@acm.org> References: <2A87D378-9FB9-4FC7-951E-5BA9832051CF@acm.org> <837drhjglr.fsf@gnu.org> <834kmljd01.fsf@gnu.org> <2C183F78-8E7D-48AE-BCC2-1E32EC0A4E29@acm.org> <83zh4dhui0.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="392"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44173@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 23 19:32:27 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kW0vS-000AXs-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Oct 2020 19:32:27 +0200 Original-Received: from localhost ([::1]:36776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kW0vR-0006ZO-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Oct 2020 13:32:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kW0v5-0006Z6-5n for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 13:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kW0v4-0001MY-MY for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 13:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kW0v4-0000QA-52 for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2020 13:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Oct 2020 17:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44173 X-GNU-PR-Package: emacs Original-Received: via spool by 44173-submit@debbugs.gnu.org id=B44173.16034743181608 (code B ref 44173); Fri, 23 Oct 2020 17:32:02 +0000 Original-Received: (at 44173) by debbugs.gnu.org; 23 Oct 2020 17:31:58 +0000 Original-Received: from localhost ([127.0.0.1]:58313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kW0uz-0000Ps-Jp for submit@debbugs.gnu.org; Fri, 23 Oct 2020 13:31:57 -0400 Original-Received: from mail204c50.megamailservers.eu ([91.136.10.214]:49768 helo=mail193c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kW0uw-0000Pd-Bw for 44173@debbugs.gnu.org; Fri, 23 Oct 2020 13:31:55 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1603474310; bh=JSg4elOzANM47jlpmp3ph6lcyex22CExIRArjHKF5hU=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=HkS2yJyvymPm67/LJNrBFi203xRcD/pNcD3c83ieLkDrK6d7X2oFWUeZRvXYPLRmM LcQUDL32GAAT7CNGCRoCdMxHMDMqJ2PGIW4JCr4H64NYEQP0fi4JkAtDWebbQioGdV v4tehkesA9drsnQ4rs+Oc0RKe6cKF8UQdY/9ryzI= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 09NHVlTs014193; Fri, 23 Oct 2020 17:31:49 +0000 In-Reply-To: <83zh4dhui0.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F26.5F931386.0042:SCFSTAT76743386, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=cM2eTWWN c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=JmvihpTtNtbsZxv4WTAA:9 a=CjuIK1q_8ugA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:191386 Archived-At: 23 okt. 2020 kl. 16.44 skrev Eli Zaretskii : > There's nothing special in the text "\303" that says it must be an > octal escape. They are just 4 ASCII characters. The grammar uses the name 'c-string', so it is reasonable to assume that = most of the lexical conventions of C strings are obeyed. Perhaps you mean that \ooo can occur outside c-string productions? If = so, please say where you have seen it, or have evidence of it being = produced. The possibilities are limited. For example, stream records may use an = unquoted (newline-terminated) string in place of a c-string, but I = haven't seen any evidence of this in practice and it appears that = gdb-mi.el does not handle that case either. The only other possibility in the grammar would be inside 'variable' = productions (field keys) which are unquoted, but those only come from a = small set of fixed names. To be clear: the exact encoding of non-ASCII bytes (whether present = literally or as octal escapes in c-string tokens) is unclear, and I do = not attempt to solve that problem here and now. This is about more = fundamental parsing and lexing problems. Namely: handling octal escapes in gdb-gdbmi-marker-filter is doing it at = the wrong level. Moreover, this substitution, when performed, is not = correct since it ignores the context; the 4-byte (excluding quotes) = string "\\377" then appears to the user as the 2-byte string "\\377", = where the '\377' sequence is painted in a distinct colour and really is = the raw byte 0xff, and thus not a valid C character escape sequence. Finally, the JSON mess is evidently the wrong way to go since it does = not take care of strings properly -- and heavens know what else, since = gdb-jsonify-buffer works at the wrong level (a pattern here) by doing = regexp replacement on the whole text prior to parsing. > That doesn't really answer my question, though, about the use case > that causes such a string to be in the program. Without a use case, I > could tell you to set gdb-mi-decode-strings non-nil and be done with > it. Why a string is in a program is irrelevant; the user does not = necessarily know that. If Emacs says that a string contains six decimal = digits when it really just contains two (nonzero) bytes, then that is a = lie no matter what. > Well, I know that several possible ways exist, but each one of them > loses in some situations. You say "the code receiving the parse tree > could decide", but will that code have information to make that > decision correctly? And if you must decide in the parser, how would > you suggest to make the decision to avoid making incorrect decisions? Again that problem is outside the scope of this bug but I think we can = agree that it is easier, or at least no more difficult, to make a = correct decision knowing the context of the string than not. Let's see what a value/result parser can do and work from there.