From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 19 18:51:19 2018 Received: (at submit) by debbugs.gnu.org; 19 Aug 2018 22:51:19 +0000 Received: from localhost ([127.0.0.1]:54900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frWXV-0005RH-KF for submit@debbugs.gnu.org; Sun, 19 Aug 2018 18:51:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51407) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frWXT-0005R3-9g for submit@debbugs.gnu.org; Sun, 19 Aug 2018 18:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frWXM-0000qK-D3 for submit@debbugs.gnu.org; Sun, 19 Aug 2018 18:51:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frWXM-0000qE-AI for submit@debbugs.gnu.org; Sun, 19 Aug 2018 18:51:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frWXL-0006MN-8O for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 18:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frWXI-0000oj-2A for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 18:51:07 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:39026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frWXG-0000oC-R3 for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 18:51:03 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w7JMowtv011558; Sun, 19 Aug 2018 18:50:59 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 38F6DAE1ED; Sun, 19 Aug 2018 18:50:57 -0400 (EDT) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: 27.0.50; Assertion failure for dot-terminated large int Date: Sun, 19 Aug 2018 18:50:57 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0.9 X-NAI-Spam-Rules: 5 Rules triggered BEC_TRC1=0.4, BEC_TRC1_W_GEN_SPAM_FEATRE=0.4, GEN_SPAM_FEATRE=0.1, EDT_SA_DN_PASS=0, RV6354=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6354> : inlines <6821> : streams <1795986> : uri <2691957> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Chris Feng X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Package: Emacs Version: 27.0.50 With the nw bignum code in Emacs master, reading a large integer with trailing dot triggers an assertion failure: M-: 4294967295. RET for me triggers the problem (seen in elpa/packages/xelb/xcb-types.el). I suspect on a 64bit host you'll need: M-: 18446744073709551615. RET to trigger the same bug (the integer needs to be large enough not to fit in a Lisp fixnum but small enough to fit in a uintmax_t). The assertion that fails is the `eassert (check =3D=3D 0)` in alloc.c:make_bignum_str. BTW, I was surprised to discover that until now "42." was read as the *integer* of value 42 rather than the float of that value. I guess we're stuck with this behavior but I find it odd. Stefan In GNU Emacs 27.0.50 (build 1, x86_64-unknown-linux-gnu, GTK+ Version 3.22.= 30) of 2018-08-19 built on alfajor Repository revision: 14acf8634c0b359fbbd3234dff65b40d9a12f26d Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 System Description: Debian GNU/Linux buster/sid Recent messages: Required package =E2=80=98helm-1.0=E2=80=99 is unavailable Unable to activate package =E2=80=98ebdb-i18n-chn=E2=80=99. Required package =E2=80=98pyim-1.6.0=E2=80=99 is unavailable Loading /home/monnier/src/elisp/ProofGeneral/generic/proof-site.el (source)= ...done Loading /home/monnier/etc/emacs/X11.el (source)...done Loading /home/monnier/etc/emacs/custom.el (source)...done Ispell-kill: nil american Starting new Ispell process /usr/bin/aspell with american dictionary... Warning: hide-sublevels is obsolete! For information about GNU Emacs and the GNU system, type C-h C-a. Configured using: 'configure -C --enable-checking --with-modules --enable-check-lisp-object-= type 'CFLAGS=3D-Wall -g3 -Og -Wno-pointer-sign' PKG_CONFIG_PATH=3D/home/monnier/lib/pkgconfig' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS LCMS2 GMP Important settings: value of $LANG: fr_CH.UTF-8 locale-coding-system: utf-8-unix Major mode: InactiveMinibuffer Minor modes in effect: electric-pair-mode: t global-reveal-mode: t reveal-mode: t auto-insert-mode: t savehist-mode: t minibuffer-electric-default-mode: t global-compact-docstrings-mode: t url-handler-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t global-prettify-symbols-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-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: /home/monnier/src/emacs/elpa/packages/svg/svg hides /home/monnier/src/emacs= /work/lisp/svg /home/monnier/src/emacs/elpa/packages/ada-mode/ada-mode hides /home/monnier= /src/emacs/work/lisp/progmodes/ada-mode /home/monnier/src/emacs/elpa/packages/ada-mode/ada-stmt hides /home/monnier= /src/emacs/work/lisp/progmodes/ada-stmt /home/monnier/src/emacs/elpa/packages/ada-mode/ada-prj hides /home/monnier/= src/emacs/work/lisp/progmodes/ada-prj /home/monnier/src/emacs/elpa/packages/ada-mode/ada-xref hides /home/monnier= /src/emacs/work/lisp/progmodes/ada-xref /home/monnier/src/emacs/elpa/packages/hyperbole/set hides /home/monnier/src= /emacs/work/lisp/emacs-lisp/set /home/monnier/src/emacs/elpa/packages/landmark/landmark hides /home/monnier= /src/emacs/work/lisp/obsolete/landmark /home/monnier/src/emacs/elpa/packages/crisp/crisp hides /home/monnier/src/e= macs/work/lisp/obsolete/crisp Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec epa 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 server time-date flymake-proc flymake compile comint ansi-color ring warnings noutline outline easy-mmode flyspell ispell checkdoc thingatpt load-dir elec-pair reveal autoinsert proof-site proof-autoloads cl pg-vars savehist minibuf-eldef disp-table compact-docstrings kotl-autoloads advice info realgud-recursive-autoloads url-auth finder-inf package let-alist derived pcase cl-extra help-mode easymenu cl-seq inline url-handlers url-parse auth-source eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq byte-opt gv bytecomp byte-compile cconv epg epg-config subr-x cl-loaddefs cl-lib 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 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 threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 8 176553 15999) (symbols 24 25413 1) (strings 16 53114 3586) (string-bytes 1 1719428) (vectors 12 22395) (vector-slots 4 633679 13932) (floats 8 74 43) (intervals 28 255 0) (buffers 536 14)) From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 21 18:52:49 2018 Received: (at 32476-done) by debbugs.gnu.org; 21 Aug 2018 22:52:49 +0000 Received: from localhost ([127.0.0.1]:57122 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fsFW5-0001Ce-1S for submit@debbugs.gnu.org; Tue, 21 Aug 2018 18:52:49 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fsFW2-0001CQ-RF for 32476-done@debbugs.gnu.org; Tue, 21 Aug 2018 18:52:47 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6717F160192; Tue, 21 Aug 2018 15:52:40 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 5ZUuwyzEze7y; Tue, 21 Aug 2018 15:52:39 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 87EE61605B1; Tue, 21 Aug 2018 15:52:39 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RP92T2_qRwpN; Tue, 21 Aug 2018 15:52:39 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 455DE160192; Tue, 21 Aug 2018 15:52:39 -0700 (PDT) To: Stefan Monnier From: Paul Eggert Subject: Re: 27.0.50; Assertion failure for dot-terminated large int Organization: UCLA Computer Science Department Message-ID: <098c494b-4b76-45e6-376d-ed8ae1d19222@cs.ucla.edu> Date: Tue, 21 Aug 2018 15:52:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------B4DD5C864F20B851510BE3CB" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32476-done Cc: 32476-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------B4DD5C864F20B851510BE3CB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for reporting that; I installed the attached to fix it. --------------B4DD5C864F20B851510BE3CB Content-Type: text/x-patch; name="0001-Fix-assertion-failure-when-reading-BIGNUM.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-assertion-failure-when-reading-BIGNUM.patch" >From f8069952abf147d090032ad6b941a728cad2c496 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 21 Aug 2018 15:49:01 -0700 Subject: [PATCH] Fix assertion failure when reading 'BIGNUM.' Problem reported by Stefan Monnier (Bug#32476). * src/lread.c (string_to_number): Don't pass leading "+" or trailing "." or junk to make_bignum_str. * test/src/lread-tests.el (lread-string-to-number-trailing-dot): New test. --- src/lread.c | 21 ++++++++++++++++----- test/src/lread-tests.el | 9 +++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/lread.c b/src/lread.c index df2fe58120..5e1bd419fa 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3710,8 +3710,9 @@ string_to_number (char const *string, int base, int flags) IEEE floating point hosts, and works around a formerly-common bug where atof ("-0.0") drops the sign. */ bool negative = *cp == '-'; + bool positive = *cp == '+'; - bool signedp = negative || *cp == '+'; + bool signedp = negative | positive; cp += signedp; enum { INTOVERFLOW = 1, LEAD_INT = 2, DOT_CHAR = 4, TRAIL_INT = 8, @@ -3732,6 +3733,7 @@ string_to_number (char const *string, int base, int flags) n += digit; } } + char const *after_digits = cp; if (*cp == '.') { state |= DOT_CHAR; @@ -3807,10 +3809,19 @@ string_to_number (char const *string, int base, int flags) return make_fixnum (negative ? -signed_n : signed_n); } - /* Skip a leading "+". */ - if (signedp && !negative) - ++string; - return make_bignum_str (string, base); + /* Trim any leading "+" and trailing nondigits, then convert to + bignum. */ + string += positive; + if (!*after_digits) + return make_bignum_str (string, base); + ptrdiff_t trimmed_len = after_digits - string; + USE_SAFE_ALLOCA; + char *trimmed = SAFE_ALLOCA (trimmed_len + 1); + memcpy (trimmed, string, trimmed_len); + trimmed[trimmed_len] = '\0'; + Lisp_Object result = make_bignum_str (trimmed, base); + SAFE_FREE (); + return result; } /* Either the number uses float syntax, or it does not fit into a fixnum. diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 17381340c7..f19d98320a 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -209,4 +209,13 @@ lread-tests--last-message (should-error (let ((load-force-doc-strings t)) (read "#[0 \"\"]")))) +(ert-deftest lread-string-to-number-trailing-dot () + (dolist (n (list (* most-negative-fixnum most-negative-fixnum) + (1- most-negative-fixnum) most-negative-fixnum + (1+ most-negative-fixnum) -1 0 1 + (1- most-positive-fixnum) most-positive-fixnum + (1+ most-positive-fixnum) + (* most-positive-fixnum most-positive-fixnum))) + (should (= n (string-to-number (format "%d." n)))))) + ;;; lread-tests.el ends here -- 2.17.1 --------------B4DD5C864F20B851510BE3CB-- From unknown Tue Sep 09 18:22:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 19 Sep 2018 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator