Subject: Re: bug#27779: #27779; C stack overflow from `read' on deeply nested lisp object.

From: Keith David Bershatsky <[email-masked]>
Date: Thu, 02 May 2019 01:00:35 -0700

TWO (2) TESTS:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TEST # 1.

SOURCE:  git clone -b emacs-26 git://git.sv.gnu.org/emacs.git

CONFIGURE:

CFLAGS='-Wall -O2 -g3' ./configure \
--with-ns \
--enable-checking='yes,glyphs' \
--enable-check-lisp-object-type \
--without-compress-install \
--without-makeinfo \
--with-gnutls=no \
--with-mailutils \
--without-makeinfo

LISP:

(require 'cl-lib)

(defun make-deep-object (depth)
    (let ((obj 1))
      (while (> (cl-decf depth) 0)
        (setq obj (vector (list obj))))
      obj))

;;; STACK OVERFLOW:  problem with `read'
;;; The bug was introduced on December 8, 2016 with
;;; commit:  f0a1e9ec3fba3d5bea5bd62f525dba3fb005d1b1
(let* ((print-circle t)
       (max-lisp-eval-depth most-positive-fixnum)
       (max-specpdl-size most-positive-fixnum)
       (deep-object (make-deep-object 6000))
       (string (prin1-to-string deep-object))
       (result (read string)))
  (when result
    (message "Bug #27779:  Success! (%d)" (length string))))

TEST:  Lanched without the terminal by opening Emacs.app.

RESULT:  Bug #27779:  Success! (23997)

No need to set the terminal with "ulimit -S -s unlimited" before launching Emacs from the terminal.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TEST # 2.

SOURCE:  git clone -b emacs-26 git://git.sv.gnu.org/emacs.git

CONFIGURE:

CFLAGS='-Wall -O0 -g3' ./configure \
--with-ns \
--enable-check-lisp-object-type \
--without-compress-install \
--without-makeinfo \
--with-gnutls=no \
--with-mailutils \
--without-makeinfo

LISP:

(require 'cl-lib)

(defun make-deep-object (depth)
    (let ((obj 1))
      (while (> (cl-decf depth) 0)
        (setq obj (vector (list obj))))
      obj))

;;; STACK OVERFLOW:  problem with `read'
;;; The bug was introduced on December 8, 2016 with
;;; commit:  f0a1e9ec3fba3d5bea5bd62f525dba3fb005d1b1
(let* ((print-circle t)
       (max-lisp-eval-depth most-positive-fixnum)
       (max-specpdl-size most-positive-fixnum)
       (deep-object (make-deep-object 6000))
       (string (prin1-to-string deep-object))
       (result (read string)))
  (when result
    (message "Bug #27779:  Success! (%d)" (length string))))

TEST:  Lanched without the terminal by opening Emacs.app.

RESULT:  Re-entering top level after C stack overflow

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [05-02-2019 00:26:45] <2 May 2019 00:26:45 -0700>
> From: Paul Eggert <[email-masked]>
> To: Keith David Bershatsky <[email-masked]>, Noam Postavsky <[email-masked]>
> Cc: [email-masked], [email-masked]
> Subject: Re: bug#27779: #27779; C stack overflow from `read' on deeply nested lisp object.
> 
> Keith David Bershatsky wrote:
> > CONFIGURE:  CFLAGS='-Wall -O0 -g3' ./configure \
> >              --with-ns \
> >              --enable-checking='yes,glyphs' \
> >              --enable-check-lisp-object-type \
> >              --without-compress-install \
> >              --without-makeinfo \
> >              --with-gnutls=no \
> >              --with-mailutils \
> >              --without-makeinfo
> 
> What happens if you try it with -O2 rather than -O0?
> 
> Also, what happens if you try it without --enable-checking='yes,glyphs'?
> 
> I have a suspicion that the debugging options are blowing the stack.