GNU bug report logs - #31995
Condition-case can't catch C stack overflow

Previous Next

Package: emacs;

Reported by: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>

Date: Thu, 28 Jun 2018 17:02:02 UTC

Severity: normal

Tags: wontfix

Found in version 26.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31995 in the body.
You can then email your comments to 31995 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31995; Package emacs. (Thu, 28 Jun 2018 17:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 28 Jun 2018 17:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; Condition-case failed to catch error
Date: Thu, 28 Jun 2018 09:54:41 -0700
[Message part 1 (text/plain, inline)]
I was trying to read code of undo-tree when I encounter this problem.
Here is a somewhat simplified version with some debug output (and the
offending undo-tree file can be found in attachment or at
https://dimlight.tk/~yangsheng/undo-tree):

'''
(defun load-undo-tree-history ()
   (interactive)
   (let ((filename "~/undo-tree"))
     (with-temp-buffer
       (insert-file-contents filename)
       (goto-char (point-min))
       (condition-case err
         (progn
           (message "before reading hash")
           (setq hash (read (current-buffer)))
           (message "before reading tree")
           (setq tree (read (current-buffer)))
           (message "after reading tree"))
         (error (message "error caught")))
       (message "outside condition-case")
    (kill-buffer nil))))
'''

The undo-tree file contains two lines, the first is a hash, and the
second is a undo-tree structure printed with ~prin1~. Some error will
happen in the second ~(read (current-buffer))~, so the expected behavior
is the following output:

'''
before reading hash
before reading tree
error caught
outside condition-case
'''

However, here is what I get.

'''
before reading hash
before reading tree
Re-entering top level after C stack overflow
'''

It seems that the function call ~(read (current-buffer))~ causes C stack
overflow. Though I personally believe the undo-tree file is not
corrupted, I assume this error should be caught by condition-case even
if the file to read is indeed corrupted.

I bisected with git (using current master head d0e2a341dd) and found the
first commit that introduced this (not exactly the same) problem was

commit f0a1e9ec3fba3d5bea5bd62f525dba3fb005d1b1
Author: Paul Eggert
Date: Thu Dec 8 11:32:48 2016 -0800

Make read1 more reentrant

This is needed if ‘read’ is called soon after startup, before the
Unicode tables have been set up, and it reads a \N escape and
needs to look up a value the Unicode tables, a lookup that in turn
calls read1 recursively. Although this change doesn’t make ‘read’
fully reentrant, it’s good enough to handle this case.
,* src/lread.c (read_buffer_size, read_buffer): Remove static vars.
(grow_read_buffer): Revamp to use locals, not statics, and to
record memory allocation un the specpdl. All callers changed.
(read1): Start with a stack-based buffer, and use the heap
only if the stack buffer is too small. Use unbind_to to
free any heap buffer allocated. Use bool for boolean.
Redo symbol loop so that only one call to grow_read_buffer
is needed.
(init_obarray): Remove no-longer-needed initialization.

Starting from this commit, the previous elisp code will crash emacs. An
attempt to fix this problem is

commit 9dee1c884eb50ba282eb9dd2495c5269add25963
Author: Paul Eggert
Date: Fri Jul 14 04:54:05 2017 -0700

Improve stack-overflow heuristic on GNU/Linux

Problem reported by Steve Kemp (Bug#27585).
,* src/eval.c (near_C_stack_top): Remove. All uses replaced
by current_thread->stack_top.
(record_in_backtrace): Set current_thread->stack_top.
This is for when the Lisp interpreter calls itself.
,* src/lread.c (read1): Set current_thread->stack_top.
This is for recursive s-expression reads.
,* src/print.c (print_object): Set current_thread->stack_top.
This is for recursive s-expression printing.
,* src/thread.c (mark_one_thread): Get stack top first.
,* src/thread.h (struct thread_state.stack_top): Now void *, not char *.

This commit fixed the crashing problem, but error catching still does
not work. As indicated in commit 9dee1c88, this commit tries to fix
Bug#27585, where Steve Kemp triggered it with a huge number of '`' or
',' . Wrapping these '`' or ',' with condition-case can also trigger the
problem.


Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
-fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2

Important settings:
value of $LANG: zh_CN.utf-8
value of $XMODIFIERS: @im=fcitx
locale-coding-system: utf-8-unix

Major mode: Spacemacs buffer

Minor modes in effect:
highlight-changes-visible-mode: t
TeX-PDF-mode: t
TeX-source-correlate-mode: t
global-vi-tilde-fringe-mode: t
pupo-mode: t
purpose-mode: t
spaceline-info-mode: t
spaceline-helm-mode: t
projectile-mode: t
company-statistics-mode: t
eval-sexp-fu-flash-mode: t
global-semanticdb-minor-mode: t
recentf-mode: t
global-semantic-idle-scheduler-mode: t
global-semantic-idle-summary-mode: t
flycheck-pos-tip-mode: t
global-flycheck-mode: t
yas-global-mode: t
yas-minor-mode: t
global-atomic-chrome-edit-mode: t
dired-omit-mode: t
engine-mode: t
company-quickhelp-mode: t
company-quickhelp-local-mode: t
pdf-occur-global-minor-mode: t
global-semantic-stickyfunc-mode: t
semantic-mode: t
show-smartparens-global-mode: t
show-smartparens-mode: t
flyspell-lazy-mode: t
global-magit-file-mode: t
diff-auto-refine-mode: t
winner-mode: t
winum-mode: t
save-place-mode: t
savehist-mode: t
persp-mode: t
global-pangu-spacing-mode: t
pangu-spacing-mode: t
global-git-gutter+-mode: t
global-git-commit-mode: t
async-bytecomp-package-mode: t
flx-ido-mode: t
eyebrowse-mode: t
global-evil-surround-mode: t
evil-surround-mode: t
evil-lion-mode: t
evil-escape-mode: t
global-anzu-mode: t
anzu-mode: t
editorconfig-mode: t
counsel-mode: t
ivy-mode: t
clean-aindent-mode: t
ace-pinyin-global-mode: t
ace-pinyin-mode: t
which-key-mode: t
override-global-mode: t
global-undo-tree-mode: t
undo-tree-mode: t
evil-mode: t
evil-local-mode: t
spacemacs-leader-override-mode: t
global-spacemacs-leader-override-mode: t
global-hl-line-mode: t
xterm-mouse-mode: t
global-auto-revert-mode: t
shell-dirtrack-mode: t
ido-vertical-mode: t
global-page-break-lines-mode: t
page-break-lines-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t

Load-path shadows:
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-plot
hides /usr/share/emacs/26.1/lisp/org/org-plot
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-stan
hides /usr/share/emacs/26.1/lisp/org/ob-stan
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-processing
hides /usr/share/emacs/26.1/lisp/org/ob-processing
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-colview
hides /usr/share/emacs/26.1/lisp/org/org-colview
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-man
hides /usr/share/emacs/26.1/lisp/org/ox-man
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-org
hides /usr/share/emacs/26.1/lisp/org/ox-org
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-makefile
hides /usr/share/emacs/26.1/lisp/org/ob-makefile
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-org
hides /usr/share/emacs/26.1/lisp/org/ob-org
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-gnus
hides /usr/share/emacs/26.1/lisp/org/org-gnus
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-sed
hides /usr/share/emacs/26.1/lisp/org/ob-sed
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-java
hides /usr/share/emacs/26.1/lisp/org/ob-java
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-latex
hides /usr/share/emacs/26.1/lisp/org/ox-latex
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-habit
hides /usr/share/emacs/26.1/lisp/org/org-habit
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-feed
hides /usr/share/emacs/26.1/lisp/org/org-feed
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-duration
hides /usr/share/emacs/26.1/lisp/org/org-duration
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-calc
hides /usr/share/emacs/26.1/lisp/org/ob-calc
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-css
hides /usr/share/emacs/26.1/lisp/org/ob-css
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-protocol
hides /usr/share/emacs/26.1/lisp/org/org-protocol
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-timer
hides /usr/share/emacs/26.1/lisp/org/org-timer
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-J
hides /usr/share/emacs/26.1/lisp/org/ob-J
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-icalendar
hides /usr/share/emacs/26.1/lisp/org/ox-icalendar
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-forth
hides /usr/share/emacs/26.1/lisp/org/ob-forth
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-C
hides /usr/share/emacs/26.1/lisp/org/ob-C
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-lilypond
hides /usr/share/emacs/26.1/lisp/org/ob-lilypond
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-list
hides /usr/share/emacs/26.1/lisp/org/org-list
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-inlinetask
hides /usr/share/emacs/26.1/lisp/org/org-inlinetask
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-loaddefs
hides /usr/share/emacs/26.1/lisp/org/org-loaddefs
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-agenda
hides /usr/share/emacs/26.1/lisp/org/org-agenda
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-ctags
hides /usr/share/emacs/26.1/lisp/org/org-ctags
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-ascii
hides /usr/share/emacs/26.1/lisp/org/ox-ascii
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-indent
hides /usr/share/emacs/26.1/lisp/org/org-indent
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-gnuplot
hides /usr/share/emacs/26.1/lisp/org/ob-gnuplot
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-mobile
hides /usr/share/emacs/26.1/lisp/org/org-mobile
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-info
hides /usr/share/emacs/26.1/lisp/org/org-info
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-irc
hides /usr/share/emacs/26.1/lisp/org/org-irc
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ledger
hides /usr/share/emacs/26.1/lisp/org/ob-ledger
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-asymptote
hides /usr/share/emacs/26.1/lisp/org/ob-asymptote
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-io
hides /usr/share/emacs/26.1/lisp/org/ob-io
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-fortran
hides /usr/share/emacs/26.1/lisp/org/ob-fortran
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox
hides /usr/share/emacs/26.1/lisp/org/ox
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-w3m
hides /usr/share/emacs/26.1/lisp/org/org-w3m
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-compat
hides /usr/share/emacs/26.1/lisp/org/org-compat
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-mouse
hides /usr/share/emacs/26.1/lisp/org/org-mouse
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-sass
hides /usr/share/emacs/26.1/lisp/org/ob-sass
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ocaml
hides /usr/share/emacs/26.1/lisp/org/ob-ocaml
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-faces
hides /usr/share/emacs/26.1/lisp/org/org-faces
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-python
hides /usr/share/emacs/26.1/lisp/org/ob-python
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-perl
hides /usr/share/emacs/26.1/lisp/org/ob-perl
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-vala
hides /usr/share/emacs/26.1/lisp/org/ob-vala
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-scheme
hides /usr/share/emacs/26.1/lisp/org/ob-scheme
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ref
hides /usr/share/emacs/26.1/lisp/org/ob-ref
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-footnote
hides /usr/share/emacs/26.1/lisp/org/org-footnote
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-entities
hides /usr/share/emacs/26.1/lisp/org/org-entities
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-element
hides /usr/share/emacs/26.1/lisp/org/org-element
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-table
hides /usr/share/emacs/26.1/lisp/org/ob-table
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-crypt
hides /usr/share/emacs/26.1/lisp/org/org-crypt
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-publish
hides /usr/share/emacs/26.1/lisp/org/ox-publish
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-clock
hides /usr/share/emacs/26.1/lisp/org/org-clock
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-R
hides /usr/share/emacs/26.1/lisp/org/ob-R
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-src
hides /usr/share/emacs/26.1/lisp/org/org-src
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ebnf
hides /usr/share/emacs/26.1/lisp/org/ob-ebnf
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-macs
hides /usr/share/emacs/26.1/lisp/org/org-macs
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-clojure
hides /usr/share/emacs/26.1/lisp/org/ob-clojure
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-haskell
hides /usr/share/emacs/26.1/lisp/org/ob-haskell
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-tangle
hides /usr/share/emacs/26.1/lisp/org/ob-tangle
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-rmail
hides /usr/share/emacs/26.1/lisp/org/org-rmail
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-bbdb
hides /usr/share/emacs/26.1/lisp/org/org-bbdb
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-bibtex
hides /usr/share/emacs/26.1/lisp/org/org-bibtex
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-lob
hides /usr/share/emacs/26.1/lisp/org/ob-lob
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-groovy
hides /usr/share/emacs/26.1/lisp/org/ob-groovy
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-lua
hides /usr/share/emacs/26.1/lisp/org/ob-lua
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-lisp
hides /usr/share/emacs/26.1/lisp/org/ob-lisp
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-html
hides /usr/share/emacs/26.1/lisp/org/ox-html
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-keys
hides /usr/share/emacs/26.1/lisp/org/ob-keys
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ruby
hides /usr/share/emacs/26.1/lisp/org/ob-ruby
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-mscgen
hides /usr/share/emacs/26.1/lisp/org/ob-mscgen
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-abc
hides /usr/share/emacs/26.1/lisp/org/ob-abc
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-core
hides /usr/share/emacs/26.1/lisp/org/ob-core
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-maxima
hides /usr/share/emacs/26.1/lisp/org/ob-maxima
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-ditaa
hides /usr/share/emacs/26.1/lisp/org/ob-ditaa
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob
hides /usr/share/emacs/26.1/lisp/org/ob
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-sqlite
hides /usr/share/emacs/26.1/lisp/org/ob-sqlite
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-eshell
hides /usr/share/emacs/26.1/lisp/org/org-eshell
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-lint
hides /usr/share/emacs/26.1/lisp/org/org-lint
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-table
hides /usr/share/emacs/26.1/lisp/org/org-table
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-datetree
hides /usr/share/emacs/26.1/lisp/org/org-datetree
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-js
hides /usr/share/emacs/26.1/lisp/org/ob-js
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-md
hides /usr/share/emacs/26.1/lisp/org/ox-md
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-beamer
hides /usr/share/emacs/26.1/lisp/org/ox-beamer
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-hledger
hides /usr/share/emacs/26.1/lisp/org/ob-hledger
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-odt
hides /usr/share/emacs/26.1/lisp/org/ox-odt
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-dot
hides /usr/share/emacs/26.1/lisp/org/ob-dot
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-archive
hides /usr/share/emacs/26.1/lisp/org/org-archive
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-pcomplete
hides /usr/share/emacs/26.1/lisp/org/org-pcomplete
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-shen
hides /usr/share/emacs/26.1/lisp/org/ob-shen
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ox-texinfo
hides /usr/share/emacs/26.1/lisp/org/ox-texinfo
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-octave
hides /usr/share/emacs/26.1/lisp/org/ob-octave
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-picolisp
hides /usr/share/emacs/26.1/lisp/org/ob-picolisp
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-macro
hides /usr/share/emacs/26.1/lisp/org/org-macro
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-plantuml
hides /usr/share/emacs/26.1/lisp/org/ob-plantuml
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org
hides /usr/share/emacs/26.1/lisp/org/org
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-sql
hides /usr/share/emacs/26.1/lisp/org/ob-sql
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-emacs-lisp
hides /usr/share/emacs/26.1/lisp/org/ob-emacs-lisp
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-coq
hides /usr/share/emacs/26.1/lisp/org/ob-coq
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-matlab
hides /usr/share/emacs/26.1/lisp/org/ob-matlab
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-docview
hides /usr/share/emacs/26.1/lisp/org/org-docview
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-id
hides /usr/share/emacs/26.1/lisp/org/org-id
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-exp
hides /usr/share/emacs/26.1/lisp/org/ob-exp
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-shell
hides /usr/share/emacs/26.1/lisp/org/ob-shell
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-eww
hides /usr/share/emacs/26.1/lisp/org/org-eww
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-attach
hides /usr/share/emacs/26.1/lisp/org/org-attach
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-capture
hides /usr/share/emacs/26.1/lisp/org/org-capture
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-install
hides /usr/share/emacs/26.1/lisp/org/org-install
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-mhe
hides /usr/share/emacs/26.1/lisp/org/org-mhe
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-latex
hides /usr/share/emacs/26.1/lisp/org/ob-latex
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-comint
hides /usr/share/emacs/26.1/lisp/org/ob-comint
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-awk
hides /usr/share/emacs/26.1/lisp/org/ob-awk
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/org-version
hides /usr/share/emacs/26.1/lisp/org/org-version
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-eval
hides /usr/share/emacs/26.1/lisp/org/ob-eval
/home/yangsheng/.emacs.d/elpa/26.1/develop/org-plus-contrib-20180611/ob-screen
hides /usr/share/emacs/26.1/lisp/org/ob-screen

Features:
(shadow emacsbug mailalias mailclient sendmail qp mail-extr sort view
reftex-global magit-ediff evil-ediff ediff-merg ediff-wind ediff-diff
ediff-mult ediff-help ediff-init ediff-util ediff vc vc-dispatcher
gravatar url-cache org-timer org-clock expand-region
text-mode-expansions cc-mode-expansions the-org-mode-expansions
ruby-mode-expansions python-el-fgallina-expansions latex-mode-expansions
js2-mode-expansions js-mode-expansions web-mode-expansions
html-mode-expansions css-mode-expansions er-basic-expansions
expand-region-core expand-region-custom hide-comnt helm-find handwrite
hangul hanja-util quail helm-id-utils cal-bahai helm-sys helm-color
simple-httpd helm-eshell cal-china-x help-at-pt highlight-indentation
helm-config helm-easymenu helm-semantic helm-man hashcash helm-ring
cal-hebrew helm-dabbrev htmlfontify htmlfontify-loaddefs files-x mmm-erb
mmm-region mmm-auto mmm-vars mmm-utils mmm-compat helm-for-files
helm-bookmark helm-external helm-net helm-command helm-mode helm-org
cal-islam tutorial helm-elisp helm-files helm-buffers helm-tags
helm-locate helm-eval edebug helm-info holidays hol-loaddefs hexl
helm-make htmlize helm-grep helm-regexp helm-adaptive helm-misc
helm-types helm-elisp-package helm-font haml-mode smartparens-markdown
markdown-mode css-mode eww smartparens-ruby ruby-mode hanoi helm-imenu
helm-utils helm-help hilit-chg hungry-delete helm helm-source
helm-multi-match helm-lib canlock use-package-lint use-package-jump
whitespace semantic/tag-write fill-column-indicator magit-gitflow
pcre2el rxt re-builder semantic/edit semantic/analyze/complete
semantic/db-typecache org-duration cal-julian diary-lib diary-loaddefs
cal-iso org-agenda tabify elfeed-link org-projectile
org-category-capture org-capture reftex-index reftex-sel reftex-ref
reftex-cite reftex-parse texmathp pdf-sync pdf-annot pdf-outline
pdf-links pdf-history latexenc paren hippie-exp company-web-html
company-web company-css web-completion-data emmet-mode web-mode
ibuffer-projectile timezone elfeed-goodies-logging
elfeed-goodies-new-entry-hooks mm-url elfeed-goodies-split-pane
elfeed-goodies-show-mode noflet cl-indent elfeed-goodies-search-mode
elfeed-goodies elfeed-org elfeed-show elfeed-search shr svg elfeed-csv
elfeed elfeed-curl elfeed-log elfeed-db elfeed-lib url-queue browse-url
xml-query conf-mode company-shell flycheck-bashate sh-script smie
executable preview prv-emacs company-auctex tex-fold reftex-dcr
reftex-auc reftex reftex-loaddefs reftex-vars font-latex auctex-latexmk
tex-buf latex latex-flymake flymake-proc flymake tex-ispell tex-style
tex smartparens-latex tex-mode cl-print debug two-column iso-transl
network-stream starttls importmagic anaconda-mode pythonic hi-lock
evil-matchit evil-matchit-sdk semantic/wisent/python
semantic/wisent/python-wy smartparens-python python
semantic/decorate/mode org-eldoc org-journal org-crypt evil-org
org-table ob-python ob-C ob-js ob-shell ob-latex org-bullets
org-download toc-org image-file org-rmail org-mhe org-irc org-info
org-gnus nnir gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap
nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range
gnus-win gnus nnheader org-docview doc-view org-bibtex bibtex org-bbdb
org-w3m vc-git flycheck-rust stickyfunc-enhance company-c-headers
semantic/db-file data-debug cedet-files ggtags ewoc tramp-cache tramp-sh
colir smex vi-tilde-fringe spacemacs-purpose-popwin window-purpose-x
imenu-list window-purpose window-purpose-fixes
window-purpose-prefix-overload window-purpose-switch
window-purpose-layout spaceline-config spaceline-segments spaceline
powerline powerline-separators powerline-themes projectile grep
company-statistics company-files company-keywords company-etags
company-gtags company-template company-dabbrev-code company-dabbrev
company-yasnippet company-capf overseer pkg-info epl auto-compile packed
elisp-slime-nav eval-sexp-fu highlight font-lock+ frame-fns avoid
semantic/db-mode srefactor srefactor-ui recentf tree-widget
srecode/semantic semantic/senator semantic/decorate srecode/insert
srecode/filters srecode/args ede/speedbar ede/files ede ede/detect
ede/base ede/auto ede/source eieio-speedbar eieio-custom srecode/find
srecode/map srecode/ctxt srecode/compile srecode/dictionary
srecode/table srecode semantic/doc semantic/bovine/c hideif
semantic/bovine/c-by semantic/lex-spp semantic/idle semantic/bovine/gcc
semantic/dep semantic/analyze/refs semantic/db-find semantic/db-ref
semantic/analyze semantic/sort semantic/scope semantic/analyze/fcn
goto-addr bug-reference auto-highlight-symbol evil-lisp-state
flycheck-pos-tip flycheck highlight-numbers parent-mode
highlight-parentheses hideshow rainbow-delimiters yasnippet-snippets
yasnippet rainbow-mode color elec-pair window-purpose-core
window-purpose-configuration window-purpose-utils atomic-chrome
websocket bindat cnfonts cnfonts-ui cal-china lunar solar cal-dst
eterm-256color term ehelp dired-x ranger ivy-rich engine-mode
company-jed

-- 
Sheng Yang(杨圣)
PhD student
Computer Science Department
University of Maryland, College Park
E-mail:yangsheng6810 <at> gmail.com

[Message part 2 (text/html, inline)]
[undo-tree (text/plain, attachment)]

Changed bug title to 'Condition-case can't catch C stack overflow' from '26.1; Condition-case failed to catch error' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 11 Jul 2018 21:49:02 GMT) Full text and rfc822 format available.

Added tag(s) wontfix. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 11 Jul 2018 21:49:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31995; Package emacs. (Wed, 11 Jul 2018 21:50:02 GMT) Full text and rfc822 format available.

Message #12 received at 31995 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>
Cc: 31995 <at> debbugs.gnu.org
Subject: Re: bug#31995: 26.1; Condition-case failed to catch error
Date: Wed, 11 Jul 2018 17:48:53 -0400
retitle 31995 Condition-case can't catch C stack overflow
tags 31995 + wontfix
quit

Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com> writes:

> It seems that the function call ~(read (current-buffer))~ causes C stack
> overflow. Though I personally believe the undo-tree file is not
> corrupted, I assume this error should be caught by condition-case even
> if the file to read is indeed corrupted.

The file is not corrupted, it's just that the recursion goes too deep
during reading.  However, I don't think condition-case can reasonably
catch C stack overflow.  As it is, recovering from C stack overflow at
all is a bit controversial, which is why we have the
attempt-stack-overflow-recovery variable which you can set to nil in
order to reliably segfault instead.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31995; Package emacs. (Thu, 12 Jul 2018 05:47:02 GMT) Full text and rfc822 format available.

Message #15 received at 31995 <at> debbugs.gnu.org (full text, mbox):

From: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31995 <at> debbugs.gnu.org
Subject: Re: bug#31995: 26.1; Condition-case failed to catch error
Date: Wed, 11 Jul 2018 22:46:21 -0700
[Message part 1 (text/plain, inline)]
condition-case was able to catch C stack overflow before commit
f0a1e9ec. I understand that recovering from C stack overflow is magical
and can be tricky, but emacs is capable of this thanks to all of your
efforts. The only part missing is re-throwing this as a lisp exception,
which should not be as hard as recovering from C stack overflow.

Here is why this feature can be important. When we open a file,
find-file-hook will call many functions, including but not limited to
undo-tree. These functions read additional files (undo-tree, project
file, dir-local, etc.) and perform tasks. To guard against file
corruption and other problems, all reads are wrapped in some try-catch
clause. However, the trust in these try-catch clauses are let down, and
a single file corruption (or a file that can cause C stack overflow)
ruins the whole process of loading file with a mysterious message
of"Recovered from C stack overflow". I don't think this is acceptable.

From a lisp programmer's perspective, if exceptions should occur, they
should be caught. This is exactly the behavior that condition-case and
other try-catch clause promise.

I am not an expert in C, debugging the C part of emacs can be painful
for me. Therefore I bisected and found the offending commits (see my
original bug report). Hope this can help you pin point the problem and
fix the bug.

On 07/11/2018 02:48 PM, Noam Postavsky wrote:
> retitle 31995 Condition-case can't catch C stack overflow
> tags 31995 + wontfix
> quit
>
> Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com> writes:
>
>> It seems that the function call ~(read (current-buffer))~ causes C stack
>> overflow. Though I personally believe the undo-tree file is not
>> corrupted, I assume this error should be caught by condition-case even
>> if the file to read is indeed corrupted.
> The file is not corrupted, it's just that the recursion goes too deep
> during reading.  However, I don't think condition-case can reasonably
> catch C stack overflow.  As it is, recovering from C stack overflow at
> all is a bit controversial, which is why we have the
> attempt-stack-overflow-recovery variable which you can set to nil in
> order to reliably segfault instead.

-- 
Sheng Yang(杨圣)
PhD student
Computer Science Department
University of Maryland, College Park
E-mail:yangsheng6810 <at> gmail.com

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31995; Package emacs. (Fri, 13 Jul 2018 00:30:01 GMT) Full text and rfc822 format available.

Message #18 received at 31995 <at> debbugs.gnu.org (full text, mbox):

From: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, 31995 <at> debbugs.gnu.org
Subject: Re: bug#31995: 26.1; Condition-case failed to catch error
Date: Thu, 12 Jul 2018 17:29:44 -0700
[Message part 1 (text/plain, inline)]
@Paul Eggert: I am cc-ing you because you are the author of commit
f0a1e9ec and may be more familiar with this topic.

Please ignore my previous email, I thought condition-case WAS able to
catch C stack overflow before commit f0a1e9ec, but it seems not the
case, or at least not related to this bug.

After some code reading and debugging, I find the problem: in commit
f0a1e9ec, the read_buffer for read1 is moved from a static variable to
an array stackbuf of size MAX_ALLOCA located on stack. MAX_ALLOCA is
defined to be 16 * 1024. So every recursion of read1 will eat up 16KB of
stack, and thousands of recursions (not uncommon for a deeply nested
structure) quickly use up whole stack and cause stack overflow.

One solution is to make stackbuf much smaller. I set it to 16, and this
bug disappeared. Though 16 may be too aggressive, 16 * 1024 is way too
big for a stack-based buffer in a function that may recur thousands of
times. To make things worse, the buffer is totally a waste of space when
read1 is dealing with everything ("[", "]", "(", ")", "#", "=", numbers,
etc.) other than the name of a symbol (usually tens of characters) or a
string, which is the only case when we would need a really long buffer.
A conservative choice would be a number higher than 40 or 80, making the
buffer long enough to hold any symbol, as people usually do not have
symbol longer than the one of half the width of a terminal. A more
aggressive choice is to totally remove the buffer and only allocate it
on heap. This comes at a cost of possible slow down because memory
allocation on heap is usually slower than on stack. The reason why this
was not the case before commit f0a1e9ec is that this buffer is reused by
every recursion of read1, and is not a problem.

As a reference, MAX_ALLOCA is defined in src/lisp.h for SAFE_ALLOCA,
which allocate memory on stack if its size is less than MAX_ALLOCA, and
allocate memory on heap otherwise. The usage for SAFE_ALLOCA and a
preparation macro USE_SAFE_ALLOCA seems pretty complicated and I am not
able to figure out.

On 07/11/2018 10:46 PM, Sheng Yang (杨圣) wrote:
> condition-case was able to catch C stack overflow before commit
> f0a1e9ec. I understand that recovering from C stack overflow is
> magical and can be tricky, but emacs is capable of this thanks to all
> of your efforts. The only part missing is re-throwing this as a lisp
> exception, which should not be as hard as recovering from C stack
> overflow.
>
> Here is why this feature can be important. When we open a file,
> find-file-hook will call many functions, including but not limited to
> undo-tree. These functions read additional files (undo-tree, project
> file, dir-local, etc.) and perform tasks. To guard against file
> corruption and other problems, all reads are wrapped in some try-catch
> clause. However, the trust in these try-catch clauses are let down,
> and a single file corruption (or a file that can cause C stack
> overflow) ruins the whole process of loading file with a mysterious
> message of"Recovered from C stack overflow". I don't think this is
> acceptable.
>
> From a lisp programmer's perspective, if exceptions should occur, they
> should be caught. This is exactly the behavior that condition-case and
> other try-catch clause promise.
>
> I am not an expert in C, debugging the C part of emacs can be painful
> for me. Therefore I bisected and found the offending commits (see my
> original bug report). Hope this can help you pin point the problem and
> fix the bug.
>
> On 07/11/2018 02:48 PM, Noam Postavsky wrote:
>> retitle 31995 Condition-case can't catch C stack overflow
>> tags 31995 + wontfix
>> quit
>>
>> Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com> writes:
>>
>>> It seems that the function call ~(read (current-buffer))~ causes C stack
>>> overflow. Though I personally believe the undo-tree file is not
>>> corrupted, I assume this error should be caught by condition-case even
>>> if the file to read is indeed corrupted.
>> The file is not corrupted, it's just that the recursion goes too deep
>> during reading.  However, I don't think condition-case can reasonably
>> catch C stack overflow.  As it is, recovering from C stack overflow at
>> all is a bit controversial, which is why we have the
>> attempt-stack-overflow-recovery variable which you can set to nil in
>> order to reliably segfault instead.
>
> -- 
> Sheng Yang(杨圣)
> PhD student
> Computer Science Department
> University of Maryland, College Park
> E-mail:yangsheng6810 <at> gmail.com

-- 
Sheng Yang(杨圣)
PhD student
Computer Science Department
University of Maryland, College Park
E-mail:yangsheng6810 <at> gmail.com

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31995; Package emacs. (Fri, 13 Jul 2018 03:44:01 GMT) Full text and rfc822 format available.

Message #21 received at 31995 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com>,
 Noam Postavsky <npostavs <at> gmail.com>
Cc: 31995 <at> debbugs.gnu.org
Subject: Re: bug#31995: 26.1; Condition-case failed to catch error
Date: Thu, 12 Jul 2018 22:43:38 -0500
[Message part 1 (text/plain, inline)]
On 07/12/2018 07:29 PM, Sheng Yang (杨圣) wrote:
> the buffer is totally a waste of space when read1 is dealing with
> everything ("[", "]", "(", ")", "#", "=", numbers, etc.) other than
> the name of a symbol (usually tens of characters) or a string
Thanks for reporting this. I attempted to work around the immediate
problem by installing the attached into the emacs-26 branch. Although
this doesn't address the overall problem of stack overflow, that is less
pressing.
[0001-Lessen-stack-consumption-in-recursive-read1.patch (text/x-patch, attachment)]

bug closed, send any further explanations to 31995 <at> debbugs.gnu.org and Sheng Yang (杨圣) <yangsheng6810 <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 27 Jun 2019 22:45:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 26 Jul 2019 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 148 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.