From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Fussner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#52438: 29.0.50; [PATCH] Fix off-by-one error in etags.c TeX support Date: Sat, 11 Dec 2021 18:50:24 +0000 Message-ID: Reply-To: David Fussner Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000a213aa05d2e35139" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7017"; mail-complaints-to="usenet@ciao.gmane.io" To: 52438@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 11 19:58:11 2021 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 1mw7ZR-0001f8-DU for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Dec 2021 19:58:09 +0100 Original-Received: from localhost ([::1]:51412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mw7ZP-0003UM-Nk for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Dec 2021 13:58:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw7ZK-0003UD-9b for bug-gnu-emacs@gnu.org; Sat, 11 Dec 2021 13:58:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mw7ZK-0001Ht-1C for bug-gnu-emacs@gnu.org; Sat, 11 Dec 2021 13:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mw7ZK-00079Q-0n for bug-gnu-emacs@gnu.org; Sat, 11 Dec 2021 13:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: David Fussner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Dec 2021 18:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52438 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163924905127448 (code B ref -1); Sat, 11 Dec 2021 18:58:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Dec 2021 18:57:31 +0000 Original-Received: from localhost ([127.0.0.1]:49993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mw7Yp-00078d-4s for submit@debbugs.gnu.org; Sat, 11 Dec 2021 13:57:31 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:53070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mw7Yn-00078V-1w for submit@debbugs.gnu.org; Sat, 11 Dec 2021 13:57:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw7Ym-0003Tn-QS for bug-gnu-emacs@gnu.org; Sat, 11 Dec 2021 13:57:28 -0500 Original-Received: from [2607:f8b0:4864:20::733] (port=34323 helo=mail-qk1-x733.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mw7Yl-0001Gb-0R for bug-gnu-emacs@gnu.org; Sat, 11 Dec 2021 13:57:28 -0500 Original-Received: by mail-qk1-x733.google.com with SMTP id t6so10776965qkg.1 for ; Sat, 11 Dec 2021 10:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Sjq2izSkovJF/gYw3ywdmDGhZWHtR/6tEttPScd7wKQ=; b=aGFoGrKSpBV5fpjNr1i2SJOjrPAsuaSxDzmFOd/HmzYOPM7U7vQr40oYRsk6M8s3Zm FXII6KNGN0sI8k/nQGpcf+zGvyNgyAsQrnddA9QPG+Nb7wxdrRFW/OFgIjiqDENYACSb jvirsxhRP4hxWuTibVwWXReACvVjmJK+jL8dEVxrZ/B82MBLOaDuO3YKLKk4jaTQ9/cx ubXdH76I3TwPkn5LwTiqJ6okEA8rQ3I3w9CZ+MZbPVce9EckyjtwQhA45j5QxkRstBS+ Ari+TaZiva0b6OGVgoCV1VTxbkw+8VRBAAcU64QdwonJcnt9zHjw+JdsChGXSACkwrfD efqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Sjq2izSkovJF/gYw3ywdmDGhZWHtR/6tEttPScd7wKQ=; b=QEiwBsuofBNaMm5G57uDQF15PIhpqQUOCUJMnmHnu5kw7tTnc6qyZiDcD3RRisSaSp RrrMU06IbEVVARMsIvDDjf2UuMkDNtsIvjsvjk/Xem2f7b9sNvnbNupndAqjafF9Hnvt xOaQHo7op2V+b+/kq7J6erormwFbaj3Q5gmySn+Lkua13z2UY3aI0BxB3PfsBIpAglXf bDMajo73c7/cWjgGcdgD2iRUt6yJh8BliKtsJi5MaSeTL7heuWW1wlM0eFepg0w/TlrN VABeflIQWvxRvnl/rqQ6Aq2jGRU1PDo3HzRFcB3vjjgbXpAbLY0gPQgUeqBe1beC3ZKM 9Oig== X-Gm-Message-State: AOAM533h2iHfeh0OgFiF3ePUcMtJSFaslgx/YzslqdF+wZ6JK5uK1ivd pCzwRq6jdSFl9OJ0Q/DtjiCf2k2Iej8oTKh3PHDkdzyyw8XcpA== X-Google-Smtp-Source: ABdhPJz674cu95ecHB3luq+JWGOyBksXaa3cGFC8Z2ewFvrk7vNWuHGGiarxRfW3QfNRXZP11KAWGE1jTvZEzjdv2Bo= X-Received: by 2002:a05:622a:1483:: with SMTP id t3mr35126115qtx.518.1639248652508; Sat, 11 Dec 2021 10:50:52 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::733 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=dfussner@googlemail.com; helo=mail-qk1-x733.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:222139 Archived-At: --000000000000a213aa05d2e35139 Content-Type: text/plain; charset="UTF-8" The etags program reliably crashes for me when running the test suite in test/manual/etags, but you need to have a long-enough TEXTAGS environment variable to make it happen. On my 32-bit GNU/Linux machine, going to that directory and running: TEXTAGS="A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X" make check crashes the program before it finishes the first run, that is, before it stops because the test suite itself fails. Removing one member of TEXTAGS allows it to complete, whereupon the test suite (correctly) fails in the normal way. Adding members gives me different crash messages. (The crash may well be machine and compiler dependent, so if it fails to crash then adding things to TEXTAGS may work.) Whether the program completes or no, and so long as you have something in TEXTAGS, running etags under valgrind always gives the following messages: ==14977== Invalid write of size 4 ==14977== at 0x804EF32: TEX_decode_env (etags.c:5808) ==14977== Invalid write of size 4 ==14977== at 0x804EF39: TEX_decode_env (etags.c:5809) Lines 5808-9 add NULL to end TEX_toktab, and the latter therefore needs to have one more slot allotted than there are actual members of the string made from the default defenv (defined in etags.c) and the TEXTAGS environment variable. When allocating storage, the code counts colons, and since the default defenv begins with a colon, it always gets the extra slot by default when there is no TEXTAGS environment variable (and those messages no longer appear under valgrind). Define a TEXTAGS variable, which according to the documentation doesn't start with a colon, and there will be one slot too few. The patch tests for whether the final concatenated string starts with a colon or not, and increments the starting value of len in TEX_toktab if it doesn't. (Apologies for the long report -- I was sort of assuming that this might be difficult to reproduce.) Thanks, David. In GNU Emacs 29.0.50 (build 3, i686-pc-linux-gnu, GTK+ Version 3.18.9, cairo version 1.14.6) of 2021-12-11 built on newfont Repository revision: 8c50016b100ec2c548ec90131e0f5fb5f4ebb5c1 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.11803000 System Description: Slackware 14.2 Configured using: 'configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LC_COLLATE: C value of $LANG: en_US.ISO8859-1 locale-coding-system: iso-latin-1-unix Major mode: C/*l Minor modes in effect: global-git-commit-mode: t magit-auto-revert-mode: t auto-revert-mode: t shell-dirtrack-mode: t bug-reference-prog-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t indent-tabs-mode: t abbrev-mode: t Load-path shadows: /home/dfussner/.emacs.d/elpa/transient-20210426.2141/transient hides /home/dfussner/src/emacs/emacs/lisp/transient Features: (shadow sort mail-extr emacsbug sendmail magit-extras face-remap magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff git-commit rx log-edit message yank-media rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor magit-mode transient cl-extra help-mode format-spec magit-git magit-section magit-utils crm dash misearch multi-isearch shell pcomplete compile text-property-search comint ansi-color ring vc-git diff-mode easy-mmode vc vc-dispatcher bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs doom-opera-theme doom-themes doom-themes-base time-date server preview-latex auto-loads tex-site finder-inf info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 8 373679 54043) (symbols 24 21995 1) (strings 16 103078 4463) (string-bytes 1 2950986) (vectors 8 45064) (vector-slots 4 1306902 95228) (floats 8 245 822) (intervals 28 7124 442) (buffers 564 20) (heap 1024 33446 1163)) --000000000000a213aa05d2e35139 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Fix-off-by-one-error-in-etags.c-TeX-support.patch" Content-Disposition: attachment; filename="0001-Fix-off-by-one-error-in-etags.c-TeX-support.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kx2677wy0 RnJvbSBmYzNhMjA3MDc0NjY2NjUwZmVlNzUyMzU5YmE4N2M5NmExN2Y5NmI5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEYXZpZCBGdXNzbmVyIDxkZnVzc25lckBnb29nbGVtYWlsLmNv bT4KRGF0ZTogU2F0LCAxMSBEZWMgMjAyMSAxNzo0NzozOCArMDAwMApTdWJqZWN0OiBbUEFUQ0hd IEZpeCBvZmYtYnktb25lIGVycm9yIGluIGV0YWdzLmMgVGVYIHN1cHBvcnQKCiogbGliLXNyYy9l dGFncy5jIChURVhfZGVjb2RlX2Vudik6IEZpeCBvZm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GxpbmVidWZmZXIpOwotLSAKMi4xNy42Cgo= --000000000000a213aa05d2e35139--