all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: 31072@debbugs.gnu.org
Subject: bug#31072: 27.0.50; Assertion failure in defvar
Date: Fri, 06 Apr 2018 15:57:40 +0000	[thread overview]
Message-ID: <CAArVCkSS_c5SyU8r=y_PD-zMKRr8WSPJO=DBti_Td0KOpdRenA@mail.gmail.com> (raw)
In-Reply-To: <m2in95jfe9.fsf@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 464 bytes --]

Philipp <p.stephani2@gmail.com> schrieb am Fr., 6. Apr. 2018 um 03:25 Uhr:

>
> Loading the following file triggers an assertion failure:
>
> ;;; -*- lexical-binding: t; -*-
> (defvar 1)
>
> $ emacs -Q -batch -l /tmp/crash.el
> eval.c:772: Emacs fatal error: assertion failed: SYMBOLP (sym)
> Fatal error 6: Abort trapAbort trap: 6
>
> This is because Fdefvar lacks a CHECK_SYMBOL in the second branch
> (lexical binding but only one argument)
>

Here is a patch.

[-- Attachment #1.2: Type: text/html, Size: 776 bytes --]

[-- Attachment #2: 0001-Avoid-undefined-behavior-in-defvar-Bug-31072.txt --]
[-- Type: text/plain, Size: 1278 bytes --]

From e4e301c8228e6d29cec6b44d86da47a0db8f3e0c Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Fri, 6 Apr 2018 17:55:59 +0200
Subject: [PATCH] Avoid undefined behavior in 'defvar' (Bug#31072)

* src/eval.c (Fdefvar): Check that first argument is a symbol.
* test/src/eval-tests.el (defvar/bug31072): New unit test.
---
 src/eval.c             | 2 ++
 test/src/eval-tests.el | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/src/eval.c b/src/eval.c
index a6e1d86c4a..90d8c33518 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -737,6 +737,8 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING)  */)
   sym = XCAR (args);
   tail = XCDR (args);
 
+  CHECK_SYMBOL (sym);
+
   if (!NILP (tail))
     {
       if (!NILP (XCDR (tail)) && !NILP (XCDR (XCDR (tail))))
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 59da6b7cc3..319dd91c86 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -113,4 +113,8 @@ eval-tests--exceed-specbind-limit
         (signal-hook-function #'ignore))
     (should-error (eval-tests--exceed-specbind-limit))))
 
+(ert-deftest defvar/bug31072 ()
+  "Check that Bug#31072 is fixed."
+  (should-error (eval '(defvar 1) t) :type 'wrong-type-argument))
+
 ;;; eval-tests.el ends here
-- 
2.17.0


  reply	other threads:[~2018-04-06 15:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06  1:24 bug#31072: 27.0.50; Assertion failure in defvar Philipp
2018-04-06 15:57 ` Philipp Stephani [this message]
2018-04-10 22:47 ` Paul Eggert
2018-04-16  6:50   ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkSS_c5SyU8r=y_PD-zMKRr8WSPJO=DBti_Td0KOpdRenA@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=31072@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.