unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
@ 2017-01-08  7:31 Thierry Volpiatto
  2017-01-08 15:08 ` npostavs
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Volpiatto @ 2017-01-08  7:31 UTC (permalink / raw)
  To: 25391


Reproduce from emacs -Q:

1) require ffap.
2) Open a file of about 560k containing only one line, e.g
"~/emacs.d/elpa/archives/archive-contents"
3) M-: (ffap-guesser)

Debugger entered--Lisp error: (error "Variable binding depth exceeds max-specpdl-size")
  looking-at("^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$")
  ffap-gopher-at-point()
  ffap-guesser()
  eval((ffap-guesser) nil)
  eval-expression((ffap-guesser) nil)
  funcall-interactively(eval-expression (ffap-guesser) nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

This is reproductible from emacs-26 as well.



In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
 of 2016-11-09 on dell-14z
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
System Description:	Linux Mint 17.3 Rosa

Configured using:
 `configure CFLAGS=-O3'

Important settings:
  value of $LC_MONETARY: fr_FR.UTF-8
  value of $LC_NUMERIC: fr_FR.UTF-8
  value of $LC_TIME: fr_FR.UTF-8
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  global-disable-mouse-mode: t
  global-git-gutter-mode: t
  eldoc-in-minibuffer-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  psession-mode: t
  dired-async-mode: t
  display-time-mode: t
  winner-mode: t
  auto-image-file-mode: t
  savehist-mode: t
  show-paren-mode: t
  helm-descbinds-mode: t
  helm-top-poll-mode: t
  helm-push-mark-mode: t
  eldoc-mode: t
  helm-mode: t
  shell-dirtrack-mode: t
  helm-adaptive-mode: t
  helm-popup-tip-mode: t
  async-bytecomp-package-mode: t
  minibuffer-depth-indicate-mode: t
  override-global-mode: t
  tooltip-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
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
uncompressing window.el.gz...done
Setting up indent for shell type bash
Indentation variables are now local.
Indentation setup for shell type bash
uncompressing reposition.el.gz...done
Restoring buffers...77%
Configuring package slime...done
Restoring buffers...82%
uncompressing imenu.el.gz...done
Restoring buffers...done

Load-path shadows:
/home/thierry/.emacs.d/elpa/org-20161224/ob-keys hides /usr/local/share/emacs/24.5/lisp/org/ob-keys
/home/thierry/.emacs.d/elpa/org-20161224/ob-ref hides /usr/local/share/emacs/24.5/lisp/org/ob-ref
/home/thierry/.emacs.d/elpa/org-20161224/ox-org hides /usr/local/share/emacs/24.5/lisp/org/ox-org
/home/thierry/.emacs.d/elpa/org-20161224/ob-sass hides /usr/local/share/emacs/24.5/lisp/org/ob-sass
/home/thierry/.emacs.d/elpa/org-20161224/org-bbdb hides /usr/local/share/emacs/24.5/lisp/org/org-bbdb
/home/thierry/.emacs.d/elpa/org-20161224/ox-latex hides /usr/local/share/emacs/24.5/lisp/org/ox-latex
/home/thierry/.emacs.d/elpa/org-20161224/ox-beamer hides /usr/local/share/emacs/24.5/lisp/org/ox-beamer
/home/thierry/.emacs.d/elpa/org-20161224/org-crypt hides /usr/local/share/emacs/24.5/lisp/org/org-crypt
/home/thierry/.emacs.d/elpa/org-20161224/ob-maxima hides /usr/local/share/emacs/24.5/lisp/org/ob-maxima
/home/thierry/.emacs.d/elpa/org-20161224/ob-R hides /usr/local/share/emacs/24.5/lisp/org/ob-R
/home/thierry/.emacs.d/elpa/org-20161224/ob-eval hides /usr/local/share/emacs/24.5/lisp/org/ob-eval
/home/thierry/.emacs.d/elpa/org-20161224/org-datetree hides /usr/local/share/emacs/24.5/lisp/org/org-datetree
/home/thierry/.emacs.d/elpa/org-20161224/org-element hides /usr/local/share/emacs/24.5/lisp/org/org-element
/home/thierry/.emacs.d/elpa/org-20161224/ob-core hides /usr/local/share/emacs/24.5/lisp/org/ob-core
/home/thierry/.emacs.d/elpa/org-20161224/ox-md hides /usr/local/share/emacs/24.5/lisp/org/ox-md
/home/thierry/.emacs.d/elpa/org-20161224/org-indent hides /usr/local/share/emacs/24.5/lisp/org/org-indent
/home/thierry/.emacs.d/elpa/org-20161224/ox hides /usr/local/share/emacs/24.5/lisp/org/ox
/home/thierry/.emacs.d/elpa/org-20161224/ob-fortran hides /usr/local/share/emacs/24.5/lisp/org/ob-fortran
/home/thierry/.emacs.d/elpa/org-20161224/ob-matlab hides /usr/local/share/emacs/24.5/lisp/org/ob-matlab
/home/thierry/.emacs.d/elpa/org-20161224/org-macro hides /usr/local/share/emacs/24.5/lisp/org/org-macro
/home/thierry/.emacs.d/elpa/org-20161224/ox-texinfo hides /usr/local/share/emacs/24.5/lisp/org/ox-texinfo
/home/thierry/.emacs.d/elpa/org-20161224/ob-sqlite hides /usr/local/share/emacs/24.5/lisp/org/ob-sqlite
/home/thierry/.emacs.d/elpa/org-20161224/org-faces hides /usr/local/share/emacs/24.5/lisp/org/org-faces
/home/thierry/.emacs.d/elpa/org-20161224/org-pcomplete hides /usr/local/share/emacs/24.5/lisp/org/org-pcomplete
/home/thierry/.emacs.d/elpa/org-20161224/org-mouse hides /usr/local/share/emacs/24.5/lisp/org/org-mouse
/home/thierry/.emacs.d/elpa/org-20161224/ob-emacs-lisp hides /usr/local/share/emacs/24.5/lisp/org/ob-emacs-lisp
/home/thierry/.emacs.d/elpa/org-20161224/org-archive hides /usr/local/share/emacs/24.5/lisp/org/org-archive
/home/thierry/.emacs.d/elpa/org-20161224/org-capture hides /usr/local/share/emacs/24.5/lisp/org/org-capture
/home/thierry/.emacs.d/elpa/org-20161224/ob-awk hides /usr/local/share/emacs/24.5/lisp/org/ob-awk
/home/thierry/.emacs.d/elpa/org-20161224/ob-octave hides /usr/local/share/emacs/24.5/lisp/org/ob-octave
/home/thierry/.emacs.d/elpa/org-20161224/org-timer hides /usr/local/share/emacs/24.5/lisp/org/org-timer
/home/thierry/.emacs.d/elpa/org-20161224/ob-sql hides /usr/local/share/emacs/24.5/lisp/org/ob-sql
/home/thierry/.emacs.d/elpa/org-20161224/ob-latex hides /usr/local/share/emacs/24.5/lisp/org/ob-latex
/home/thierry/.emacs.d/elpa/org-20161224/org-macs hides /usr/local/share/emacs/24.5/lisp/org/org-macs
/home/thierry/.emacs.d/elpa/org-20161224/org-rmail hides /usr/local/share/emacs/24.5/lisp/org/org-rmail
/home/thierry/.emacs.d/elpa/org-20161224/org-w3m hides /usr/local/share/emacs/24.5/lisp/org/org-w3m
/home/thierry/.emacs.d/elpa/org-20161224/ob-io hides /usr/local/share/emacs/24.5/lisp/org/ob-io
/home/thierry/.emacs.d/elpa/org-20161224/ob hides /usr/local/share/emacs/24.5/lisp/org/ob
/home/thierry/.emacs.d/elpa/org-20161224/ob-perl hides /usr/local/share/emacs/24.5/lisp/org/ob-perl
/home/thierry/.emacs.d/elpa/org-20161224/ob-mscgen hides /usr/local/share/emacs/24.5/lisp/org/ob-mscgen
/home/thierry/.emacs.d/elpa/org-20161224/ob-lilypond hides /usr/local/share/emacs/24.5/lisp/org/ob-lilypond
/home/thierry/.emacs.d/elpa/org-20161224/org-footnote hides /usr/local/share/emacs/24.5/lisp/org/org-footnote
/home/thierry/.emacs.d/elpa/org-20161224/ob-java hides /usr/local/share/emacs/24.5/lisp/org/ob-java
/home/thierry/.emacs.d/elpa/org-20161224/ox-html hides /usr/local/share/emacs/24.5/lisp/org/ox-html
/home/thierry/.emacs.d/elpa/org-20161224/ob-haskell hides /usr/local/share/emacs/24.5/lisp/org/ob-haskell
/home/thierry/.emacs.d/elpa/org-20161224/org-docview hides /usr/local/share/emacs/24.5/lisp/org/org-docview
/home/thierry/.emacs.d/elpa/org-20161224/ob-comint hides /usr/local/share/emacs/24.5/lisp/org/ob-comint
/home/thierry/.emacs.d/elpa/org-20161224/ob-css hides /usr/local/share/emacs/24.5/lisp/org/ob-css
/home/thierry/.emacs.d/elpa/org-20161224/ob-ditaa hides /usr/local/share/emacs/24.5/lisp/org/ob-ditaa
/home/thierry/.emacs.d/elpa/org-20161224/ob-scala hides /usr/local/share/emacs/24.5/lisp/org/ob-scala
/home/thierry/.emacs.d/elpa/org-20161224/org hides /usr/local/share/emacs/24.5/lisp/org/org
/home/thierry/.emacs.d/elpa/org-20161224/org-mobile hides /usr/local/share/emacs/24.5/lisp/org/org-mobile
/home/thierry/.emacs.d/elpa/org-20161224/ob-lisp hides /usr/local/share/emacs/24.5/lisp/org/ob-lisp
/home/thierry/.emacs.d/elpa/org-20161224/ob-gnuplot hides /usr/local/share/emacs/24.5/lisp/org/ob-gnuplot
/home/thierry/.emacs.d/elpa/org-20161224/org-src hides /usr/local/share/emacs/24.5/lisp/org/org-src
/home/thierry/.emacs.d/elpa/org-20161224/ox-ascii hides /usr/local/share/emacs/24.5/lisp/org/ox-ascii
/home/thierry/.emacs.d/elpa/org-20161224/ob-calc hides /usr/local/share/emacs/24.5/lisp/org/ob-calc
/home/thierry/.emacs.d/elpa/org-20161224/org-irc hides /usr/local/share/emacs/24.5/lisp/org/org-irc
/home/thierry/.emacs.d/elpa/org-20161224/org-loaddefs hides /usr/local/share/emacs/24.5/lisp/org/org-loaddefs
/home/thierry/.emacs.d/elpa/org-20161224/org-install hides /usr/local/share/emacs/24.5/lisp/org/org-install
/home/thierry/.emacs.d/elpa/org-20161224/org-info hides /usr/local/share/emacs/24.5/lisp/org/org-info
/home/thierry/.emacs.d/elpa/org-20161224/ob-plantuml hides /usr/local/share/emacs/24.5/lisp/org/ob-plantuml
/home/thierry/.emacs.d/elpa/org-20161224/org-feed hides /usr/local/share/emacs/24.5/lisp/org/org-feed
/home/thierry/.emacs.d/elpa/org-20161224/org-version hides /usr/local/share/emacs/24.5/lisp/org/org-version
/home/thierry/.emacs.d/elpa/org-20161224/ob-makefile hides /usr/local/share/emacs/24.5/lisp/org/ob-makefile
/home/thierry/.emacs.d/elpa/org-20161224/org-entities hides /usr/local/share/emacs/24.5/lisp/org/org-entities
/home/thierry/.emacs.d/elpa/org-20161224/ob-python hides /usr/local/share/emacs/24.5/lisp/org/ob-python
/home/thierry/.emacs.d/elpa/org-20161224/ob-ledger hides /usr/local/share/emacs/24.5/lisp/org/ob-ledger
/home/thierry/.emacs.d/elpa/org-20161224/ox-man hides /usr/local/share/emacs/24.5/lisp/org/ox-man
/home/thierry/.emacs.d/elpa/org-20161224/ob-shen hides /usr/local/share/emacs/24.5/lisp/org/ob-shen
/home/thierry/.emacs.d/elpa/org-20161224/org-inlinetask hides /usr/local/share/emacs/24.5/lisp/org/org-inlinetask
/home/thierry/.emacs.d/elpa/org-20161224/org-list hides /usr/local/share/emacs/24.5/lisp/org/org-list
/home/thierry/.emacs.d/elpa/org-20161224/ox-publish hides /usr/local/share/emacs/24.5/lisp/org/ox-publish
/home/thierry/.emacs.d/elpa/org-20161224/org-gnus hides /usr/local/share/emacs/24.5/lisp/org/org-gnus
/home/thierry/.emacs.d/elpa/org-20161224/org-agenda hides /usr/local/share/emacs/24.5/lisp/org/org-agenda
/home/thierry/.emacs.d/elpa/org-20161224/org-id hides /usr/local/share/emacs/24.5/lisp/org/org-id
/home/thierry/.emacs.d/elpa/org-20161224/org-plot hides /usr/local/share/emacs/24.5/lisp/org/org-plot
/home/thierry/.emacs.d/elpa/org-20161224/ob-C hides /usr/local/share/emacs/24.5/lisp/org/ob-C
/home/thierry/.emacs.d/elpa/org-20161224/org-clock hides /usr/local/share/emacs/24.5/lisp/org/org-clock
/home/thierry/.emacs.d/elpa/org-20161224/org-attach hides /usr/local/share/emacs/24.5/lisp/org/org-attach
/home/thierry/.emacs.d/elpa/org-20161224/ob-ruby hides /usr/local/share/emacs/24.5/lisp/org/ob-ruby
/home/thierry/.emacs.d/elpa/org-20161224/org-habit hides /usr/local/share/emacs/24.5/lisp/org/org-habit
/home/thierry/.emacs.d/elpa/org-20161224/org-eshell hides /usr/local/share/emacs/24.5/lisp/org/org-eshell
/home/thierry/.emacs.d/elpa/org-20161224/ob-ocaml hides /usr/local/share/emacs/24.5/lisp/org/ob-ocaml
/home/thierry/.emacs.d/elpa/org-20161224/ox-odt hides /usr/local/share/emacs/24.5/lisp/org/ox-odt
/home/thierry/.emacs.d/elpa/org-20161224/ob-exp hides /usr/local/share/emacs/24.5/lisp/org/ob-exp
/home/thierry/.emacs.d/elpa/org-20161224/ob-dot hides /usr/local/share/emacs/24.5/lisp/org/ob-dot
/home/thierry/.emacs.d/elpa/org-20161224/ob-scheme hides /usr/local/share/emacs/24.5/lisp/org/ob-scheme
/home/thierry/.emacs.d/elpa/org-20161224/ob-org hides /usr/local/share/emacs/24.5/lisp/org/ob-org
/home/thierry/.emacs.d/elpa/org-20161224/org-bibtex hides /usr/local/share/emacs/24.5/lisp/org/org-bibtex
/home/thierry/.emacs.d/elpa/org-20161224/org-compat hides /usr/local/share/emacs/24.5/lisp/org/org-compat
/home/thierry/.emacs.d/elpa/org-20161224/ox-icalendar hides /usr/local/share/emacs/24.5/lisp/org/ox-icalendar
/home/thierry/.emacs.d/elpa/org-20161224/org-colview hides /usr/local/share/emacs/24.5/lisp/org/org-colview
/home/thierry/.emacs.d/elpa/org-20161224/ob-picolisp hides /usr/local/share/emacs/24.5/lisp/org/ob-picolisp
/home/thierry/.emacs.d/elpa/org-20161224/org-mhe hides /usr/local/share/emacs/24.5/lisp/org/org-mhe
/home/thierry/.emacs.d/elpa/org-20161224/org-table hides /usr/local/share/emacs/24.5/lisp/org/org-table
/home/thierry/.emacs.d/elpa/org-20161224/ob-clojure hides /usr/local/share/emacs/24.5/lisp/org/ob-clojure
/home/thierry/.emacs.d/elpa/org-20161224/ob-tangle hides /usr/local/share/emacs/24.5/lisp/org/ob-tangle
/home/thierry/.emacs.d/elpa/org-20161224/ob-table hides /usr/local/share/emacs/24.5/lisp/org/ob-table
/home/thierry/.emacs.d/elpa/org-20161224/ob-asymptote hides /usr/local/share/emacs/24.5/lisp/org/ob-asymptote
/home/thierry/.emacs.d/elpa/org-20161224/org-ctags hides /usr/local/share/emacs/24.5/lisp/org/org-ctags
/home/thierry/.emacs.d/elpa/org-20161224/ob-screen hides /usr/local/share/emacs/24.5/lisp/org/ob-screen
/home/thierry/.emacs.d/elpa/org-20161224/org-protocol hides /usr/local/share/emacs/24.5/lisp/org/org-protocol
/home/thierry/.emacs.d/elpa/org-20161224/ob-js hides /usr/local/share/emacs/24.5/lisp/org/ob-js
/home/thierry/.emacs.d/elpa/org-20161224/ob-lob hides /usr/local/share/emacs/24.5/lisp/org/ob-lob
/home/thierry/.emacs.d/elpa/soap-client-3.1.1/soap-client hides /usr/local/share/emacs/24.5/lisp/net/soap-client
/home/thierry/.emacs.d/elpa/soap-client-3.1.1/soap-inspect hides /usr/local/share/emacs/24.5/lisp/net/soap-inspect

Features:
(shadow epa-mail face-remap emacsbug helm-command js imenu
slime-xref-browser tree-widget slime-banner slime-tramp slime-asdf
slime-fancy slime-trace-dialog slime-fontifying-fu slime-package-fu
slime-references slime-compiler-notes-tree slime-scratch
slime-presentations bridge slime-macrostep slime-mdot-fu
slime-enclosing-context slime-fuzzy slime-fancy-trace
slime-fancy-inspector slime-c-p-c slime-editing-commands slime-autodoc
slime-repl slime-parse slime etags arc-mode archive-mode hyperspec
make-mode cc-awk conf-mode macrostep-c subr-x cmacexp macrostep cc-langs
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs vc-rcs ledger-config ledger vc-git naquadah-theme view
mule-util solar cal-dst holidays hol-loaddefs em-unix em-term term
disp-table ehelp em-script em-prompt em-ls em-hist em-pred em-glob
em-dirs em-cmpl em-basic em-banner em-alias tv-utils gh gh-users
gh-issues gh-pulls gh-repos gh-comments gh-gist gh-oauth gh-api logito
gh-cache pcache eieio-base gh-auth gh-url url-http tls url-auth url-gw
disable-mouse powerline powerline-separators color powerline-themes
windmove benchmark-init toc-org ert ewoc debug elp cl-indent esh-var
esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg esh-groups eshell
esh-module esh-mode esh-util markdown-mode addressbook-bookmark
mu4e-config org-mu4e helm-mu mu4e-contrib mu4e desktop frameset
mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main mu4e-context
mu4e-view epa derived epg mu4e-headers mu4e-compose mu4e-draft
mu4e-actions ido rfc2368 smtpmail sendmail mu4e-mark mu4e-message
html2text mu4e-proc mu4e-utils mu4e-lists mu4e-vars hl-line cl mu4e-meta
config-w3m w3m-search w3m doc-view jka-compr image-mode timezone
w3m-hist w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl w3m-favicon w3m-image
w3m-proc w3m-util git-gutter cus-edit wid-edit appt diary-lib
diary-loaddefs ange-ftp xdvi-search eldoc-eval undo-tree diff
magit-obsolete magit-blame magit-stash magit-bisect magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-branch
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log magit-diff smerge-mode diff-mode magit-core
magit-autorevert autorevert filenotify magit-process magit-margin
magit-mode help-mode magit-git crm magit-section magit-popup git-commit
magit-utils log-edit message rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
mail-utils gmm-utils mailheader pcvs-util add-log with-editor tramp-sh
server pcomplete-extension pcmpl-unix pcmpl-gnu psession iterator iedit
iedit-lib dired-extension org-config-thierry ob-sh org-crypt org-element
avl-tree org-location-google-maps org-agenda google-maps
google-maps-static google-maps-geocode google-maps-base org org-macro
org-footnote org-pcomplete org-list org-faces org-entities noutline
outline org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob
ob-table ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs find-func cal-menu calendar cal-loaddefs dired-async
net-utils time winner w3m-wget wget wget-sysdep cmake-mode autotest-mode
autoconf-mode sh-script smie executable ps-print ps-def lpr rst
image-file savehist paren woman man ediff-merg ediff-wind ediff-diff
ediff-mult ediff-help ediff-init ediff-util ediff init-helm-thierry
helm-descbinds helm-sys popup helm-ring helm-elisp helm-eval edebug
eldoc helm-mode helm-files image-dired tramp tramp-compat tramp-loaddefs
trampver shell pcomplete format-spec dired-x dired-aux ffap thingatpt
helm-buffers helm-elscreen helm-tags helm-bookmark helm-adaptive
helm-info bookmark pp helm-locate helm-grep wgrep-helm wgrep grep
helm-regexp helm-external helm-net browse-url xml url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap helm-utils compile comint ansi-color ring helm-help
helm-types helm helm-source helm-multi-match helm-lib dired
helm-extensions-autoloads helm-config helm-autoloads helm-easymenu
cl-macs gv async-bytecomp advice async mb-depth edmacro kmacro
use-package diminish bind-key easy-mmode tex-site gh-common gh-profile
url-parse auth-source gnus-util mm-util help-fns mail-prsvr
password-cache url-vars rx s ucs-normalize marshal ht json dash eieio
byte-opt bytecomp byte-compile cl-extra cconv eieio-core slime-autoloads
info easymenu package epg-config time-date avoid cus-start cus-load
cl-loaddefs cl-lib tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer 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 make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 785234 224980)
 (symbols 48 66492 2)
 (miscs 40 369 2735)
 (strings 32 189134 114480)
 (string-bytes 1 5580098)
 (vectors 16 88824)
 (vector-slots 8 1295163 62942)
 (floats 8 2470 841)
 (intervals 56 2763 783)
 (buffers 960 162)
 (heap 1024 88807 14786))

-- 
Thierry





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-08  7:31 bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs Thierry Volpiatto
@ 2017-01-08 15:08 ` npostavs
  2017-01-08 17:28   ` Thierry Volpiatto
  0 siblings, 1 reply; 13+ messages in thread
From: npostavs @ 2017-01-08 15:08 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Reproduce from emacs -Q:
>
> 1) require ffap.
> 2) Open a file of about 560k containing only one line, e.g
> "~/emacs.d/elpa/archives/archive-contents"
> 3) M-: (ffap-guesser)
>
> Debugger entered--Lisp error: (error "Variable binding depth exceeds max-specpdl-size")
>   looking-at("^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$")
[...]
>
> This is reproductible from emacs-26 as well.

The max-specpdl-size error looks like #24751 (I was planning to push the
patch for that today), but as far as I know, that's only in emacs-26.
emacs-25 and earlier correctly throw "stack overflow in regexp matcher".
Unless you have REL_ALLOC enabled (which is the default for GNU/Linux
distributions with the latest glibc), in which case any buffer search
may crash emacs instead.  That's #24358, occurs in 25.1 (and probably
earlier), but it's already fixed in the emacs-25 branch.  Also fixable
by configuring with REL_ALLOC=no.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-08 15:08 ` npostavs
@ 2017-01-08 17:28   ` Thierry Volpiatto
  2017-01-08 23:29     ` npostavs
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Volpiatto @ 2017-01-08 17:28 UTC (permalink / raw)
  To: npostavs; +Cc: 25391


npostavs@users.sourceforge.net writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Reproduce from emacs -Q:
>>
>> 1) require ffap.
>> 2) Open a file of about 560k containing only one line, e.g
>> "~/emacs.d/elpa/archives/archive-contents"
>> 3) M-: (ffap-guesser)
>>
>> Debugger entered--Lisp error: (error "Variable binding depth exceeds max-specpdl-size")
>>   looking-at("^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$")
> [...]
>>
>> This is reproductible from emacs-26 as well.
>
> The max-specpdl-size error looks like #24751 (I was planning to push the
> patch for that today), but as far as I know, that's only in emacs-26.
> emacs-25 and earlier correctly throw "stack overflow in regexp matcher".
> Unless you have REL_ALLOC enabled (which is the default for GNU/Linux
> distributions with the latest glibc), in which case any buffer search
> may crash emacs instead.  That's #24358, occurs in 25.1 (and probably
> earlier), but it's already fixed in the emacs-25 branch.  Also fixable
> by configuring with REL_ALLOC=no.

Good to know thanks.

However, this handle the problem with "Stack overflow in regexp matcher"
generally, but perhaps regexps such as `ffap-gopher-regexp` could be
avoided when possible in emacs source code.

IIUC regexps like "^.*\\(this\\|that etc...\\)" create an incredible
number of travels between bol and eol (which may sometimes be eob) and
lead to a stack overflow inevitably on long lines (perhaps not so long
in this case).

Thanks.

-- 
Thierry





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-08 17:28   ` Thierry Volpiatto
@ 2017-01-08 23:29     ` npostavs
  2017-01-09  7:00       ` Thierry Volpiatto
  0 siblings, 1 reply; 13+ messages in thread
From: npostavs @ 2017-01-08 23:29 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

[-- Attachment #1: Type: text/plain, Size: 652 bytes --]

tags 25391 patch
quit

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
> However, this handle the problem with "Stack overflow in regexp matcher"
> generally, but perhaps regexps such as `ffap-gopher-regexp` could be
> avoided when possible in emacs source code.

Ah, so by "crash" you meant throw an error.

>
> IIUC regexps like "^.*\\(this\\|that etc...\\)" create an incredible
> number of travels between bol and eol (which may sometimes be eob) and
> lead to a stack overflow inevitably on long lines (perhaps not so long
> in this case).

Right, and ffap-gopher-at-point is also using `set' on local variables,
icky.  Here's a patch:


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 4854 bytes --]

From 589054b197ab4a9778454efd0192bdd45ce38518 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 8 Jan 2017 18:19:32 -0500
Subject: [PATCH v1] Improve ffap-gopher-at-point handling of long lines

* lisp/ffap.el (ffap-gopher-regexp): Remove.
(ffap--gopher-var-on-line): New function.
(ffap-gopher-at-point): Use it instead of ffap-gopher-regexp which could
overflow the regexp stack on long lines (Bug#25391).  Use `let-alist'
instead of calling `set' on local variables.
* test/lisp/ffap-tests.el (ffap-gopher-at-point): New test.
---
 lisp/ffap.el            | 61 ++++++++++++++++++++++++-------------------------
 test/lisp/ffap-tests.el | 15 ++++++++++++
 2 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 8144d41..1ef2b10 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1193,10 +1193,17 @@ ffap-url-at-point
                       (list (car bounds) (cdr bounds)))))
           val))))
 
-(defvar ffap-gopher-regexp
-  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
-  "Regexp matching a line in a gopher bookmark (maybe indented).
-The two subexpressions are the KEY and VALUE.")
+(defun ffap--gopher-var-on-line ()
+  "Return (KEY . VALUE) of gopher bookmark on current line."
+  (save-excursion
+    (let ((bol (progn (beginning-of-line) (point)))
+          (eol (progn (end-of-line) (skip-chars-backward " ") (point))))
+     (goto-char bol)
+     (when (re-search-forward
+            "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *" eol t)
+       (let ((key (match-string 1))
+             (val (buffer-substring-no-properties (match-end 0) eol)))
+         (cons (intern (downcase key)) val))))))
 
 (defun ffap-gopher-at-point ()
   "If point is inside a gopher bookmark block, return its URL.
@@ -1204,33 +1211,25 @@ ffap-gopher-at-point
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   ;; `gopher-parse-bookmark' from gopher.el is not so robust
   (save-excursion
-    (beginning-of-line)
-    (if (looking-at ffap-gopher-regexp)
-	(progn
-	  (while (and (looking-at ffap-gopher-regexp) (not (bobp)))
-	    (forward-line -1))
-	  (or (looking-at ffap-gopher-regexp) (forward-line 1))
-          (setq ffap-string-at-point-region (list (point) (point)))
-	  (let ((type "1") path host (port "70"))
-	    (while (looking-at ffap-gopher-regexp)
-	      (let ((var (intern
-			  (downcase
-			   (buffer-substring (match-beginning 1)
-					     (match-end 1)))))
-		    (val (buffer-substring (match-beginning 2)
-					   (match-end 2))))
-		(set var val)
-		(forward-line 1)))
-            (setcdr ffap-string-at-point-region (list (point)))
-	    (if (and path (string-match "^ftp:.*@" path))
-		(concat "ftp://"
-			(substring path 4 (1- (match-end 0)))
-			(substring path (match-end 0)))
-	      (and (= (length type) 1)
-		   host;; (ffap-machine-p host)
-		   (concat "gopher://" host
-			   (if (equal port "70") "" (concat ":" port))
-			   "/" type path))))))))
+    (let* ((beg (progn (beginning-of-line)
+                       (while (and (not (bobp)) (ffap--gopher-var-on-line))
+                         (forward-line -1))
+                       (point)))
+           (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
+                              while keyval collect keyval
+                              do (forward-line 1))))
+      (when bookmark
+        (setq ffap-string-at-point-region (list beg (point)))
+        (let-alist (nconc bookmark '((type . "1") (port . "70")))
+          (if (and .path (string-match "\\`ftp:.*@" .path))
+              (concat "ftp://"
+                      (substring .path 4 (1- (match-end 0)))
+                      (substring .path (match-end 0)))
+            (and (= (length .type) 1)
+                 .host ;; (ffap-machine-p host)
+                 (concat "gopher://" .host
+                         (if (equal .port "70") "" (concat ":" .port))
+                         "/" .type .path))))))))
 
 (defvar ffap-ftp-sans-slash-regexp
   (and
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 1ba5f86..f3414ac 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -49,6 +49,21 @@
               (should (equal '(1 1) ffap-string-at-point-region)))))
       (and (file-exists-p file) (delete-file file)))))
 
+(ert-deftest ffap-gopher-at-point ()
+  (with-temp-buffer
+    (insert "\
+Type = 1
+Name = foo
+Path = /the/path
+Port = 7070
+Host = example.com\n")
+    (should-not (ffap-gopher-at-point))
+    (goto-char (point-min))
+    (should (equal (ffap-gopher-at-point)
+                   "gopher://example.com:7070/1/the/path"))
+    (should (equal ffap-string-at-point-region
+                   (list (point-min) (point-max))))))
+
 (provide 'ffap-tests)
 
 ;;; ffap-tests.el ends here
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-08 23:29     ` npostavs
@ 2017-01-09  7:00       ` Thierry Volpiatto
  2017-01-10  4:37         ` npostavs
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Volpiatto @ 2017-01-09  7:00 UTC (permalink / raw)
  To: npostavs; +Cc: 25391


npostavs@users.sourceforge.net writes:

> tags 25391 patch
> quit
>
> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>>
>> However, this handle the problem with "Stack overflow in regexp matcher"
>> generally, but perhaps regexps such as `ffap-gopher-regexp` could be
>> avoided when possible in emacs source code.
>
> Ah, so by "crash" you meant throw an error.

I had the both, a crash on emacs-26, emacs taking all memory and finally
crashing and on emacs-24.5 "Stack overflow in regexp matcher".


> Right, and ffap-gopher-at-point is also using `set' on local variables,
> icky.  Here's a patch:

I don't know `let-alist`, but looks good, however keeping
`ffap-gopher-regexp` instead of hardcoding it and returning nil when the
regexp is nil would allow users to disable the feature.

Thanks.

-- 
Thierry





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-09  7:00       ` Thierry Volpiatto
@ 2017-01-10  4:37         ` npostavs
  2017-01-10  7:17           ` Thierry Volpiatto
  0 siblings, 1 reply; 13+ messages in thread
From: npostavs @ 2017-01-10  4:37 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

[-- Attachment #1: Type: text/plain, Size: 970 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

>>
>> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>>>
>>> However, this handle the problem with "Stack overflow in regexp matcher"
>>> generally, but perhaps regexps such as `ffap-gopher-regexp` could be
>>> avoided when possible in emacs source code.
>>
>> Ah, so by "crash" you meant throw an error.
>
> I had the both, a crash on emacs-26, emacs taking all memory and finally
> crashing and on emacs-24.5 "Stack overflow in regexp matcher".

Hmm, well I've meanwhile merged the fix for the regex stack limit, if
you can still crash emacs this way, open a new bug.

>
>
>> Right, and ffap-gopher-at-point is also using `set' on local variables,
>> icky.  Here's a patch:
>
> I don't know `let-alist`, but looks good, however keeping
> `ffap-gopher-regexp` instead of hardcoding it and returning nil when the
> regexp is nil would allow users to disable the feature.

Makes sense, here's an update:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4858 bytes --]

From 93875e1d9dba4509ddd18ade9b09bf6b258d2174 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 8 Jan 2017 18:19:32 -0500
Subject: [PATCH v2] Improve ffap-gopher-at-point handling of long lines

* lisp/ffap.el (ffap-gopher-regexp): Only match the KEY part.
(ffap--gopher-var-on-line): New function.
(ffap-gopher-at-point): Use it instead of the old ffap-gopher-regexp
which could overflow the regexp stack on long lines (Bug#25391).  Use
`let-alist' instead of calling `set' on local variables.
* test/lisp/ffap-tests.el (ffap-gopher-at-point): New test.
---
 lisp/ffap.el            | 61 +++++++++++++++++++++++++------------------------
 test/lisp/ffap-tests.el | 15 ++++++++++++
 2 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 8144d41..bcc8911 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1194,9 +1194,18 @@ ffap-url-at-point
           val))))
 
 (defvar ffap-gopher-regexp
-  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
-  "Regexp matching a line in a gopher bookmark (maybe indented).
-The two subexpressions are the KEY and VALUE.")
+  "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
+  "Regexp matching a key in a gopher bookmark.")
+
+(defun ffap--gopher-var-on-line ()
+  "Return (KEY . VALUE) of gopher bookmark on current line."
+  (save-excursion
+    (let ((eol (progn (end-of-line) (skip-chars-backward " ") (point)))
+          (bol (progn (beginning-of-line) (point))))
+     (when (re-search-forward ffap-gopher-regexp eol t)
+       (let ((key (match-string 1))
+             (val (buffer-substring-no-properties (match-end 0) eol)))
+         (cons (intern (downcase key)) val))))))
 
 (defun ffap-gopher-at-point ()
   "If point is inside a gopher bookmark block, return its URL.
@@ -1204,33 +1213,25 @@ ffap-gopher-at-point
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   ;; `gopher-parse-bookmark' from gopher.el is not so robust
   (save-excursion
-    (beginning-of-line)
-    (if (looking-at ffap-gopher-regexp)
-	(progn
-	  (while (and (looking-at ffap-gopher-regexp) (not (bobp)))
-	    (forward-line -1))
-	  (or (looking-at ffap-gopher-regexp) (forward-line 1))
-          (setq ffap-string-at-point-region (list (point) (point)))
-	  (let ((type "1") path host (port "70"))
-	    (while (looking-at ffap-gopher-regexp)
-	      (let ((var (intern
-			  (downcase
-			   (buffer-substring (match-beginning 1)
-					     (match-end 1)))))
-		    (val (buffer-substring (match-beginning 2)
-					   (match-end 2))))
-		(set var val)
-		(forward-line 1)))
-            (setcdr ffap-string-at-point-region (list (point)))
-	    (if (and path (string-match "^ftp:.*@" path))
-		(concat "ftp://"
-			(substring path 4 (1- (match-end 0)))
-			(substring path (match-end 0)))
-	      (and (= (length type) 1)
-		   host;; (ffap-machine-p host)
-		   (concat "gopher://" host
-			   (if (equal port "70") "" (concat ":" port))
-			   "/" type path))))))))
+    (let* ((beg (progn (beginning-of-line)
+                       (while (and (not (bobp)) (ffap--gopher-var-on-line))
+                         (forward-line -1))
+                       (point)))
+           (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
+                              while keyval collect keyval
+                              do (forward-line 1))))
+      (when bookmark
+        (setq ffap-string-at-point-region (list beg (point)))
+        (let-alist (nconc bookmark '((type . "1") (port . "70")))
+          (if (and .path (string-match "\\`ftp:.*@" .path))
+              (concat "ftp://"
+                      (substring .path 4 (1- (match-end 0)))
+                      (substring .path (match-end 0)))
+            (and (= (length .type) 1)
+                 .host ;; (ffap-machine-p host)
+                 (concat "gopher://" .host
+                         (if (equal .port "70") "" (concat ":" .port))
+                         "/" .type .path))))))))
 
 (defvar ffap-ftp-sans-slash-regexp
   (and
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 1ba5f86..f3414ac 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -49,6 +49,21 @@
               (should (equal '(1 1) ffap-string-at-point-region)))))
       (and (file-exists-p file) (delete-file file)))))
 
+(ert-deftest ffap-gopher-at-point ()
+  (with-temp-buffer
+    (insert "\
+Type = 1
+Name = foo
+Path = /the/path
+Port = 7070
+Host = example.com\n")
+    (should-not (ffap-gopher-at-point))
+    (goto-char (point-min))
+    (should (equal (ffap-gopher-at-point)
+                   "gopher://example.com:7070/1/the/path"))
+    (should (equal ffap-string-at-point-region
+                   (list (point-min) (point-max))))))
+
 (provide 'ffap-tests)
 
 ;;; ffap-tests.el ends here
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-10  4:37         ` npostavs
@ 2017-01-10  7:17           ` Thierry Volpiatto
  2017-01-10 13:37             ` npostavs
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Volpiatto @ 2017-01-10  7:17 UTC (permalink / raw)
  To: npostavs; +Cc: 25391


npostavs@users.sourceforge.net writes:

> Hmm, well I've meanwhile merged the fix for the regex stack limit, if
> you can still crash emacs this way, open a new bug.

Ok.

>> I don't know `let-alist`, but looks good, however keeping
>> `ffap-gopher-regexp` instead of hardcoding it and returning nil when the
>> regexp is nil would allow users to disable the feature.
>
> Makes sense, here's an update:

Thanks, however AFAIU your patch, when `ffap-gopher-regexp` is nil,
`ffap-gopher-at-point` will return with an error but not nil isn't it ?


-- 
Thierry





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-10  7:17           ` Thierry Volpiatto
@ 2017-01-10 13:37             ` npostavs
  2017-01-10 14:42               ` Thierry Volpiatto
  0 siblings, 1 reply; 13+ messages in thread
From: npostavs @ 2017-01-10 13:37 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

>>> I don't know `let-alist`, but looks good, however keeping
>>> `ffap-gopher-regexp` instead of hardcoding it and returning nil when the
>>> regexp is nil would allow users to disable the feature.
>>
>> Makes sense, here's an update:
>
> Thanks, however AFAIU your patch, when `ffap-gopher-regexp` is nil,
> `ffap-gopher-at-point` will return with an error but not nil isn't it ?

Yes, although that's also true before my patch.  So `ffap-gopher-regexp'
never actually supported being changed.  I'm not sure if it's a good
idea to add support for that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4996 bytes --]

From ed145acaeb5446e004fc6a38ff6411967a6a2222 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 8 Jan 2017 18:19:32 -0500
Subject: [PATCH v3] Improve ffap-gopher-at-point handling of long lines

* lisp/ffap.el (ffap-gopher-regexp): Only match the KEY part.
(ffap--gopher-var-on-line): New function.
(ffap-gopher-at-point): Use it instead of the old ffap-gopher-regexp
which could overflow the regexp stack on long lines (Bug#25391).  Use
`let-alist' instead of calling `set' on local variables.
* test/lisp/ffap-tests.el (ffap-gopher-at-point): New test.
---
 lisp/ffap.el            | 64 +++++++++++++++++++++++++------------------------
 test/lisp/ffap-tests.el | 17 +++++++++++++
 2 files changed, 50 insertions(+), 31 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 8144d41..182694a 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1194,43 +1194,45 @@ ffap-url-at-point
           val))))
 
 (defvar ffap-gopher-regexp
-  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
-  "Regexp matching a line in a gopher bookmark (maybe indented).
-The two subexpressions are the KEY and VALUE.")
+  "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
+  "Regexp matching a key in a gopher bookmark.")
+
+(defun ffap--gopher-var-on-line ()
+  "Return (KEY . VALUE) of gopher bookmark on current line."
+  (save-excursion
+    (let ((eol (progn (end-of-line) (skip-chars-backward " ") (point)))
+          (bol (progn (beginning-of-line) (point))))
+     (when (re-search-forward ffap-gopher-regexp eol t)
+       (let ((key (match-string 1))
+             (val (buffer-substring-no-properties (match-end 0) eol)))
+         (cons (intern (downcase key)) val))))))
 
 (defun ffap-gopher-at-point ()
   "If point is inside a gopher bookmark block, return its URL.
 
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   ;; `gopher-parse-bookmark' from gopher.el is not so robust
-  (save-excursion
-    (beginning-of-line)
-    (if (looking-at ffap-gopher-regexp)
-	(progn
-	  (while (and (looking-at ffap-gopher-regexp) (not (bobp)))
-	    (forward-line -1))
-	  (or (looking-at ffap-gopher-regexp) (forward-line 1))
-          (setq ffap-string-at-point-region (list (point) (point)))
-	  (let ((type "1") path host (port "70"))
-	    (while (looking-at ffap-gopher-regexp)
-	      (let ((var (intern
-			  (downcase
-			   (buffer-substring (match-beginning 1)
-					     (match-end 1)))))
-		    (val (buffer-substring (match-beginning 2)
-					   (match-end 2))))
-		(set var val)
-		(forward-line 1)))
-            (setcdr ffap-string-at-point-region (list (point)))
-	    (if (and path (string-match "^ftp:.*@" path))
-		(concat "ftp://"
-			(substring path 4 (1- (match-end 0)))
-			(substring path (match-end 0)))
-	      (and (= (length type) 1)
-		   host;; (ffap-machine-p host)
-		   (concat "gopher://" host
-			   (if (equal port "70") "" (concat ":" port))
-			   "/" type path))))))))
+  (when (stringp ffap-gopher-regexp)
+    (save-excursion
+      (let* ((beg (progn (beginning-of-line)
+                         (while (and (not (bobp)) (ffap--gopher-var-on-line))
+                           (forward-line -1))
+                         (point)))
+             (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
+                                while keyval collect keyval
+                                do (forward-line 1))))
+        (when bookmark
+          (setq ffap-string-at-point-region (list beg (point)))
+          (let-alist (nconc bookmark '((type . "1") (port . "70")))
+            (if (and .path (string-match "\\`ftp:.*@" .path))
+                (concat "ftp://"
+                        (substring .path 4 (1- (match-end 0)))
+                        (substring .path (match-end 0)))
+              (and (= (length .type) 1)
+                   .host ;; (ffap-machine-p host)
+                   (concat "gopher://" .host
+                           (if (equal .port "70") "" (concat ":" .port))
+                           "/" .type .path)))))))))
 
 (defvar ffap-ftp-sans-slash-regexp
   (and
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 1ba5f86..a3fe350 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -49,6 +49,23 @@
               (should (equal '(1 1) ffap-string-at-point-region)))))
       (and (file-exists-p file) (delete-file file)))))
 
+(ert-deftest ffap-gopher-at-point ()
+  (with-temp-buffer
+    (insert "\
+Type = 1
+Name = foo
+Path = /the/path
+Port = 7070
+Host = example.com\n")
+    (should-not (ffap-gopher-at-point))
+    (goto-char (point-min))
+    (should (equal (ffap-gopher-at-point)
+                   "gopher://example.com:7070/1/the/path"))
+    (should (equal ffap-string-at-point-region
+                   (list (point-min) (point-max))))
+    (let ((ffap-gopher-regexp nil))
+      (should-not (ffap-gopher-at-point)))))
+
 (provide 'ffap-tests)
 
 ;;; ffap-tests.el ends here
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-10 13:37             ` npostavs
@ 2017-01-10 14:42               ` Thierry Volpiatto
  2017-01-14  2:25                 ` npostavs
  0 siblings, 1 reply; 13+ messages in thread
From: Thierry Volpiatto @ 2017-01-10 14:42 UTC (permalink / raw)
  To: npostavs; +Cc: 25391


npostavs@users.sourceforge.net writes:

> Yes, although that's also true before my patch.  So `ffap-gopher-regexp'
> never actually supported being changed.  I'm not sure if it's a good
> idea to add support for that.

I think it is, gopher is not widely used AFAIK, and allowing disabling
it would avoid needless search in most cases, thus it make it consistent
with other ffap* fns that can be disabled; I have a lot of complains at
helm with ffap annoyances and having more flexibility on this is interesting.
 
> +  (when (stringp ffap-gopher-regexp)

That's what I expected.

Thanks.

-- 
Thierry





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-10 14:42               ` Thierry Volpiatto
@ 2017-01-14  2:25                 ` npostavs
  2017-01-14  6:57                   ` npostavs
       [not found]                   ` <874m12t57f.fsf@gmail.com>
  0 siblings, 2 replies; 13+ messages in thread
From: npostavs @ 2017-01-14  2:25 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> npostavs@users.sourceforge.net writes:
>
>> Yes, although that's also true before my patch.  So `ffap-gopher-regexp'
>> never actually supported being changed.  I'm not sure if it's a good
>> idea to add support for that.
>
> I think it is, gopher is not widely used AFAIK, and allowing disabling
> it would avoid needless search in most cases, thus it make it consistent
> with other ffap* fns that can be disabled; I have a lot of complains at
> helm with ffap annoyances and having more flexibility on this is interesting.

Oh, yes, if the other regexps can be disabled like that, we should make it
consistent.  I've added a note about it to the docstring and toplevel
comments; I'll push to master in a couple of days.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 5524 bytes --]

From e4904a9c5c871780b94ffd2cf433637e5d75755a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 8 Jan 2017 18:19:32 -0500
Subject: [PATCH v4] Improve ffap-gopher-at-point handling of long lines

* lisp/ffap.el (ffap-gopher-regexp): Only match the KEY part.  Note
setting to nil is now supported.
(ffap--gopher-var-on-line): New function.
(ffap-gopher-at-point): Use it instead of the old ffap-gopher-regexp
which could overflow the regexp stack on long lines (Bug#25391).  Use
`let-alist' instead of calling `set' on local variables.
* test/lisp/ffap-tests.el (ffap-gopher-at-point): New test.
---
 lisp/ffap.el            | 66 ++++++++++++++++++++++++++-----------------------
 test/lisp/ffap-tests.el | 17 +++++++++++++
 2 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 8144d41..0baf52b 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -76,6 +76,7 @@
 ;; (setq ffap-machine-p-known 'accept)  ; no pinging
 ;; (setq ffap-url-regexp nil)           ; disable URL features in ffap
 ;; (setq ffap-shell-prompt-regexp nil)  ; disable shell prompt stripping
+;; (setq ffap-gopher-regexp nil)        ; disable gopher bookmark matching
 ;;
 ;; ffap uses `browse-url' (if found, else `w3-fetch') to fetch URL's.
 ;; For a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
@@ -1194,43 +1195,46 @@ ffap-url-at-point
           val))))
 
 (defvar ffap-gopher-regexp
-  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
-  "Regexp matching a line in a gopher bookmark (maybe indented).
-The two subexpressions are the KEY and VALUE.")
+  "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
+  "Regexp matching a key in a gopher bookmark.
+Set to nil to disable matching gopher bookmarks."
+
+(defun ffap--gopher-var-on-line ()
+  "Return (KEY . VALUE) of gopher bookmark on current line."
+  (save-excursion
+    (let ((eol (progn (end-of-line) (skip-chars-backward " ") (point)))
+          (bol (progn (beginning-of-line) (point))))
+     (when (re-search-forward ffap-gopher-regexp eol t)
+       (let ((key (match-string 1))
+             (val (buffer-substring-no-properties (match-end 0) eol)))
+         (cons (intern (downcase key)) val))))))
 
 (defun ffap-gopher-at-point ()
   "If point is inside a gopher bookmark block, return its URL.
 
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   ;; `gopher-parse-bookmark' from gopher.el is not so robust
-  (save-excursion
-    (beginning-of-line)
-    (if (looking-at ffap-gopher-regexp)
-	(progn
-	  (while (and (looking-at ffap-gopher-regexp) (not (bobp)))
-	    (forward-line -1))
-	  (or (looking-at ffap-gopher-regexp) (forward-line 1))
-          (setq ffap-string-at-point-region (list (point) (point)))
-	  (let ((type "1") path host (port "70"))
-	    (while (looking-at ffap-gopher-regexp)
-	      (let ((var (intern
-			  (downcase
-			   (buffer-substring (match-beginning 1)
-					     (match-end 1)))))
-		    (val (buffer-substring (match-beginning 2)
-					   (match-end 2))))
-		(set var val)
-		(forward-line 1)))
-            (setcdr ffap-string-at-point-region (list (point)))
-	    (if (and path (string-match "^ftp:.*@" path))
-		(concat "ftp://"
-			(substring path 4 (1- (match-end 0)))
-			(substring path (match-end 0)))
-	      (and (= (length type) 1)
-		   host;; (ffap-machine-p host)
-		   (concat "gopher://" host
-			   (if (equal port "70") "" (concat ":" port))
-			   "/" type path))))))))
+  (when (stringp ffap-gopher-regexp)
+    (save-excursion
+      (let* ((beg (progn (beginning-of-line)
+                         (while (and (not (bobp)) (ffap--gopher-var-on-line))
+                           (forward-line -1))
+                         (point)))
+             (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
+                                while keyval collect keyval
+                                do (forward-line 1))))
+        (when bookmark
+          (setq ffap-string-at-point-region (list beg (point)))
+          (let-alist (nconc bookmark '((type . "1") (port . "70")))
+            (if (and .path (string-match "\\`ftp:.*@" .path))
+                (concat "ftp://"
+                        (substring .path 4 (1- (match-end 0)))
+                        (substring .path (match-end 0)))
+              (and (= (length .type) 1)
+                   .host ;; (ffap-machine-p host)
+                   (concat "gopher://" .host
+                           (if (equal .port "70") "" (concat ":" .port))
+                           "/" .type .path)))))))))
 
 (defvar ffap-ftp-sans-slash-regexp
   (and
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 1ba5f86..a3fe350 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -49,6 +49,23 @@
               (should (equal '(1 1) ffap-string-at-point-region)))))
       (and (file-exists-p file) (delete-file file)))))
 
+(ert-deftest ffap-gopher-at-point ()
+  (with-temp-buffer
+    (insert "\
+Type = 1
+Name = foo
+Path = /the/path
+Port = 7070
+Host = example.com\n")
+    (should-not (ffap-gopher-at-point))
+    (goto-char (point-min))
+    (should (equal (ffap-gopher-at-point)
+                   "gopher://example.com:7070/1/the/path"))
+    (should (equal ffap-string-at-point-region
+                   (list (point-min) (point-max))))
+    (let ((ffap-gopher-regexp nil))
+      (should-not (ffap-gopher-at-point)))))
+
 (provide 'ffap-tests)
 
 ;;; ffap-tests.el ends here
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
  2017-01-14  2:25                 ` npostavs
@ 2017-01-14  6:57                   ` npostavs
       [not found]                   ` <874m12t57f.fsf@gmail.com>
  1 sibling, 0 replies; 13+ messages in thread
From: npostavs @ 2017-01-14  6:57 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

npostavs@users.sourceforge.net writes:

>  (defvar ffap-gopher-regexp
> -  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
> -  "Regexp matching a line in a gopher bookmark (maybe indented).
> -The two subexpressions are the KEY and VALUE.")
> +  "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
> +  "Regexp matching a key in a gopher bookmark.
> +Set to nil to disable matching gopher bookmarks."

Oops, lost a close paren.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 5525 bytes --]

From 98e9ff3cb73acc5e177abc907f05bb8e3ff09712 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 8 Jan 2017 18:19:32 -0500
Subject: [PATCH v5] Improve ffap-gopher-at-point handling of long lines

* lisp/ffap.el (ffap-gopher-regexp): Only match the KEY part.  Note
setting to nil is now supported.
(ffap--gopher-var-on-line): New function.
(ffap-gopher-at-point): Use it instead of the old ffap-gopher-regexp
which could overflow the regexp stack on long lines (Bug#25391).  Use
`let-alist' instead of calling `set' on local variables.
* test/lisp/ffap-tests.el (ffap-gopher-at-point): New test.
---
 lisp/ffap.el            | 66 ++++++++++++++++++++++++++-----------------------
 test/lisp/ffap-tests.el | 17 +++++++++++++
 2 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 8144d41..068897b 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -76,6 +76,7 @@
 ;; (setq ffap-machine-p-known 'accept)  ; no pinging
 ;; (setq ffap-url-regexp nil)           ; disable URL features in ffap
 ;; (setq ffap-shell-prompt-regexp nil)  ; disable shell prompt stripping
+;; (setq ffap-gopher-regexp nil)        ; disable gopher bookmark matching
 ;;
 ;; ffap uses `browse-url' (if found, else `w3-fetch') to fetch URL's.
 ;; For a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
@@ -1194,43 +1195,46 @@ ffap-url-at-point
           val))))
 
 (defvar ffap-gopher-regexp
-  "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$"
-  "Regexp matching a line in a gopher bookmark (maybe indented).
-The two subexpressions are the KEY and VALUE.")
+  "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
+  "Regexp matching a key in a gopher bookmark.
+Set to nil to disable matching gopher bookmarks.")
+
+(defun ffap--gopher-var-on-line ()
+  "Return (KEY . VALUE) of gopher bookmark on current line."
+  (save-excursion
+    (let ((eol (progn (end-of-line) (skip-chars-backward " ") (point)))
+          (bol (progn (beginning-of-line) (point))))
+     (when (re-search-forward ffap-gopher-regexp eol t)
+       (let ((key (match-string 1))
+             (val (buffer-substring-no-properties (match-end 0) eol)))
+         (cons (intern (downcase key)) val))))))
 
 (defun ffap-gopher-at-point ()
   "If point is inside a gopher bookmark block, return its URL.
 
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   ;; `gopher-parse-bookmark' from gopher.el is not so robust
-  (save-excursion
-    (beginning-of-line)
-    (if (looking-at ffap-gopher-regexp)
-	(progn
-	  (while (and (looking-at ffap-gopher-regexp) (not (bobp)))
-	    (forward-line -1))
-	  (or (looking-at ffap-gopher-regexp) (forward-line 1))
-          (setq ffap-string-at-point-region (list (point) (point)))
-	  (let ((type "1") path host (port "70"))
-	    (while (looking-at ffap-gopher-regexp)
-	      (let ((var (intern
-			  (downcase
-			   (buffer-substring (match-beginning 1)
-					     (match-end 1)))))
-		    (val (buffer-substring (match-beginning 2)
-					   (match-end 2))))
-		(set var val)
-		(forward-line 1)))
-            (setcdr ffap-string-at-point-region (list (point)))
-	    (if (and path (string-match "^ftp:.*@" path))
-		(concat "ftp://"
-			(substring path 4 (1- (match-end 0)))
-			(substring path (match-end 0)))
-	      (and (= (length type) 1)
-		   host;; (ffap-machine-p host)
-		   (concat "gopher://" host
-			   (if (equal port "70") "" (concat ":" port))
-			   "/" type path))))))))
+  (when (stringp ffap-gopher-regexp)
+    (save-excursion
+      (let* ((beg (progn (beginning-of-line)
+                         (while (and (not (bobp)) (ffap--gopher-var-on-line))
+                           (forward-line -1))
+                         (point)))
+             (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
+                                while keyval collect keyval
+                                do (forward-line 1))))
+        (when bookmark
+          (setq ffap-string-at-point-region (list beg (point)))
+          (let-alist (nconc bookmark '((type . "1") (port . "70")))
+            (if (and .path (string-match "\\`ftp:.*@" .path))
+                (concat "ftp://"
+                        (substring .path 4 (1- (match-end 0)))
+                        (substring .path (match-end 0)))
+              (and (= (length .type) 1)
+                   .host ;; (ffap-machine-p host)
+                   (concat "gopher://" .host
+                           (if (equal .port "70") "" (concat ":" .port))
+                           "/" .type .path)))))))))
 
 (defvar ffap-ftp-sans-slash-regexp
   (and
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 1ba5f86..a3fe350 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -49,6 +49,23 @@
               (should (equal '(1 1) ffap-string-at-point-region)))))
       (and (file-exists-p file) (delete-file file)))))
 
+(ert-deftest ffap-gopher-at-point ()
+  (with-temp-buffer
+    (insert "\
+Type = 1
+Name = foo
+Path = /the/path
+Port = 7070
+Host = example.com\n")
+    (should-not (ffap-gopher-at-point))
+    (goto-char (point-min))
+    (should (equal (ffap-gopher-at-point)
+                   "gopher://example.com:7070/1/the/path"))
+    (should (equal ffap-string-at-point-region
+                   (list (point-min) (point-max))))
+    (let ((ffap-gopher-regexp nil))
+      (should-not (ffap-gopher-at-point)))))
+
 (provide 'ffap-tests)
 
 ;;; ffap-tests.el ends here
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
       [not found]                   ` <874m12t57f.fsf@gmail.com>
@ 2017-01-14 14:43                     ` Noam Postavsky
       [not found]                       ` <8737gltvw8.fsf@gmail.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Noam Postavsky @ 2017-01-14 14:43 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

On Sat, Jan 14, 2017 at 3:29 AM, Thierry Volpiatto
<thierry.volpiatto@gmail.com> wrote:
>
> npostavs@users.sourceforge.net writes:
>
>> Oh, yes, if the other regexps can be disabled like that, we should make it
>> consistent.  I've added a note about it to the docstring and toplevel
>> comments; I'll push to master in a couple of days.
>
> Great thanks, perhaps you can notify also about ffap-alist==nil which
> helps too to disable ffap.

There is already this at the top of the file:

;; (setq ffap-alist nil)                ; faster, dumber prompting

Did you have something else in mind?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs.
       [not found]                       ` <8737gltvw8.fsf@gmail.com>
@ 2017-01-15 19:08                         ` Noam Postavsky
  0 siblings, 0 replies; 13+ messages in thread
From: Noam Postavsky @ 2017-01-15 19:08 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 25391

tag 25391 fixed
close 25391 26.1
quit

On Sat, Jan 14, 2017 at 12:05 PM, Thierry Volpiatto
<thierry.volpiatto@gmail.com> wrote:
>
>>>
>>> Great thanks, perhaps you can notify also about ffap-alist==nil which
>>> helps too to disable ffap.
>>
>> There is already this at the top of the file:
>>
>> ;; (setq ffap-alist nil)                ; faster, dumber prompting
>
> Ah, good sorry I mess it.
>
>> Did you have something else in mind?
>
> No, think it's good now.
>
> Thanks.
>
> --
> Thierry

I've pushed to master [1: fd6b829]

1: 2017-01-15 13:04:54 -0500 fd6b829d91da73a945643b5916ee6d79c992e030
  Improve ffap-gopher-at-point handling of long lines





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-01-15 19:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-08  7:31 bug#25391: 24.5; ffap-guesser "stack overflow in regexp matcher" error may crash emacs Thierry Volpiatto
2017-01-08 15:08 ` npostavs
2017-01-08 17:28   ` Thierry Volpiatto
2017-01-08 23:29     ` npostavs
2017-01-09  7:00       ` Thierry Volpiatto
2017-01-10  4:37         ` npostavs
2017-01-10  7:17           ` Thierry Volpiatto
2017-01-10 13:37             ` npostavs
2017-01-10 14:42               ` Thierry Volpiatto
2017-01-14  2:25                 ` npostavs
2017-01-14  6:57                   ` npostavs
     [not found]                   ` <874m12t57f.fsf@gmail.com>
2017-01-14 14:43                     ` Noam Postavsky
     [not found]                       ` <8737gltvw8.fsf@gmail.com>
2017-01-15 19:08                         ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).