Package: emacs;
Reported by: Tadeus Prastowo <tadeus.prastowo <at> unitn.it>
Date: Sat, 30 Mar 2019 22:23:02 UTC
Severity: normal
Found in version 26.1
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Tadeus Prastowo <tadeus.prastowo <at> unitn.it> To: bug-gnu-emacs <at> gnu.org Subject: 26.1; Tetris score is no longer updated Date: Sat, 30 Mar 2019 23:22:11 +0100
Ubuntu 16.04 comes with Emacs 24, and I have played several Tetris games using it, the high scores of which are recorded in my home directory. Today, I built Emacs 26.1 and played a Tetris game using it. The resulting score, however, was not recorded although it should have been. I traced the problem to the following commit that changes the expected format of the high-score file in my home directory: -- 8< ------------------------------------------------------------------ commit 995be66f0f0d26d1a96cbb8dfb429c3941157771 Author: Paul Eggert <eggert <at> cs.ucla.edu> Date: Sun Mar 12 12:04:10 2017 -0700 Install update-game-score only on request Most distributions do not install update-game-score properly due to setuid/setgid complications, so install it only when the installer specifies a user or group (Bug#25895). * .gitattributes: Remove lib-src/update-game-score.exe.manifest. * Makefile.in (gameuser, gamegroup, use_gamedir, PATH_GAME): New vars. (epaths-force): Use PATH_GAME. (uninstall): Remove snake-scores and tetris-scores only if shared. * configure.ac: Default --with-gameuser to 'no'. (UPDATE_MANIFEST): Remove. * etc/NEWS: Mention this. * lib-src/Makefile.in (UPDATE_MANIFEST): Remove. (use_gamedir): New macro. (UTILITIES): Remove update-game-score unless use_gamedir. (SCRIPTS): Remove $(UPDATE_MANIFEST). ($(DESTDIR)${archlibdir}): Install game directory program and data only if use_gamedir. * lib-src/update-game-score.exe.manifest: Remove, as update-game-score is no longer installed on MS-Windows. * lisp/play/gamegrid.el (gamegrid-add-score-with-update-game-score): Use auxiliary program only if setuid or setgid. * make-dist: Do not distribute update-game-score.exe.manifest. * src/callproc.c (init_callproc): Set Vshared_game_score_directory based on PATH_GAME, not DOS_NT. (syms_of_callproc): Remove unnecessary initialization of Vshared_game_score_directory. -- 8< ------------------------------------------------------------------ The offending diff in the commit is shown below: -- 8< ------------------------------------------------------------------ diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index b0ccbd3..0386a89 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -497,23 +499,12 @@ FILE is created there." (expand-file-name file shared-game-score-directory) score)) ;; Else: Add the score to a score file in the user's home ;; directory. - (gamegrid-shared-game-dir - ;; If `gamegrid-shared-game-dir' is non-nil, then - ;; "update-gamescore" program is setuid, so don't use it. - (unless (file-exists-p - (directory-file-name gamegrid-user-score-file-directory)) - (make-directory gamegrid-user-score-file-directory t)) - (gamegrid-add-score-insecure file score - gamegrid-user-score-file-directory)) (t (unless (file-exists-p (directory-file-name gamegrid-user-score-file-directory)) (make-directory gamegrid-user-score-file-directory t)) - (let ((f (expand-file-name file - gamegrid-user-score-file-directory))) - (unless (file-exists-p f) - (write-region "" nil f nil 'silent nil 'excl)) - (gamegrid-add-score-with-update-game-score-1 file f score)))))) + (gamegrid-add-score-insecure file score + gamegrid-user-score-file-directory))))) (defun gamegrid-add-score-with-update-game-score-1 (file target score) (let ((default-directory "/") -- 8< ------------------------------------------------------------------ From the diff, it is clear that previously the high-score file was updated using `gamegrid-add-score-with-update-game-score-1', which writes a high-score line in the following format: (concat (int-to-string score) " " (user-login-name) " " (concat (user-full-name) " <" (cond ((fboundp 'user-mail-address) (user-mail-address)) ((boundp 'user-mail-address) user-mail-address) (t "")) "> " (current-time-string))) After the commit, the high-score file is updated using `gamegrid-add-score-insecure', which writes a high-score line in the following format: (format "%05d\t%s\t%s <%s>\n" score (current-time-string) (user-full-name) (cond ((fboundp 'user-mail-address) (user-mail-address)) ((boundp 'user-mail-address) user-mail-address) (t ""))) In my high-score file for Tetris, the lowest score (obfuscated for privacy) is as follows: 1817 XXX XXX XXX <XXX <at> XXX.XXX> XXX XXX XX XX:XX:XX XXXX So, when today I played Tetris using Emacs 26.1 and scored higher than 1817 (e.g., 2555), `gamegrid-add-score-insecure' first writes the following line: 1817 XXX XXX XXX <XXX <at> XXX.XXX> XXX XXX XX XX:XX:XX XXXX 02555 XXX XXX XX XX:XX:XX XXXX XXX XXX <XXX <at> XXX.XXX> Then, it sorts the lines using `sort-fields' on field 1. Since `sort-fiels' performs a lexicographical sort, the higher score 02555 ends up being the lowest score due to the leading 0. As a result, the new score is not recorded, leading to this reported bug. Since this is a user-visible change, the NEWS file that accompanies Emacs 26.1 (http://www.gnu.org/software/emacs/news/NEWS.26.1) ought to mention this problem. Unfortunately, the offending commit does not do so as shown below: -- 8< ------------------------------------------------------------------ diff --git a/etc/NEWS b/etc/NEWS index f0df0a7..cd829bf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -65,6 +65,11 @@ emacs-version and erc-cmd-SV functions, and the leave the following variables nil: emacs-build-system, emacs-build-time, erc-emacs-build-time. +** The configure option '--with-gameuser' now defaults to 'no', +as this appears to be the most common configuration in practice. +When it is 'no', the shared game directory and the auxiliary program +update-game-score are no longer needed and are not installed. + ** Emacs no longer works on IRIX. We expect that Emacs users are not affected by this, as SGI stopped supporting IRIX in December 2013. -- 8< ------------------------------------------------------------------ Since this seems to break for many users, in addition to fixing the NEWS file, I suggest that `gamegrid-add-score-insecure' be fixed to work with the high-score line format of `gamegrid-add-score-with-update-game-score-1'. Otherwise, an error message should be raised to let users quickly fix their high-score files themselves. In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2019-03-30 built on 0x657573 Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 System Description: Ubuntu 16.04.6 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure --prefix=/mnt/core/Codebases/installzone/emacs --with-xwidgets --disable-silent-rules' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS XWIDGETS LIBSYSTEMD LCMS2 Important settings: value of $LC_MONETARY: en_US.UTF-8 value of $LC_NUMERIC: en_US.UTF-8 value of $LC_TIME: en_US.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-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 transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type 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 elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 94622 8544) (symbols 48 20366 2) (miscs 40 38 118) (strings 32 28354 1003) (string-bytes 1 751654) (vectors 16 13968) (vector-slots 8 492158 10422) (floats 8 49 68) (intervals 56 220 0) (buffers 992 11) (heap 1024 34351 1010)) -- Best regards, Tadeus
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.