Subject: bug#23949: 25.0.95; Regression in handling error caused by (string-match-p "." nil)

From: Eli Zaretskii <[email-masked]>
Date: Tue, 12 Jul 2016 17:01:33 +0300

> From: Kaushal Modi <[email-masked]>
> Date: Tue, 12 Jul 2016 13:33:05 +0000
> Cc: [email-masked]
> 
> (gdb) frame 9
> #9 0x0000000000624397 in Fread_from_string (string=54138084, start=0, end=0) at lread.c:2075
> 2075 ret = read_internal_start (string, start, end);
> (gdb) p string
> $15 = 54138084
> (gdb) xstring
> $16 = (struct Lisp_String *) 0x33a14e0
> "(nilory is relative, it is com"
> 
> Looks like the 'nil' argument in '(string-match-p "." nil)' somehow did this?

string-match-p just signals an error, because its 2nd arg must be a
string.  Look up the backtrace, and you will see that Emacs is trying
to signal an error:

  #47 0x00000000005f6a41 in Fapply (nargs=2, args=0x7fffffff7270) at
  eval.c:2329
  #48 0x00000000005f6f90 in apply1 (fn=16848, arg=56618787) at eval.c:2545
  #49 0x00000000005f23b6 in call_debugger (arg=56618787) at eval.c:308
  #50 0x00000000005f4e2b in maybe_call_debugger (conditions=9578427,
  sig=51984, data=56618835) at eval.c:1723
  #51 0x00000000005f48dd in Fsignal (error_symbol=51984, data=56618835) at
  eval.c:1541
  #52 0x00000000005f4a06 in xsignal (error_symbol=51984, data=56618835) at
  eval.c:1578
  #53 0x00000000005f4a9a in xsignal2 (error_symbol=51984, arg1=44400, arg2=0)
  at eval.c:1599
  #54 0x00000000005d7967 in wrong_type_argument (predicate=44400, value=0) at
  data.c:151
  #55 0x000000000055388b in CHECK_STRING (x=0) at lisp.h:2807
  #56 0x00000000005b2278 in string_match_1 (regexp=55505044, string=0,
  start=0, posix=false) at search.c:373
  #57 0x00000000005b25e5 in Fstring_match (regexp=55505044, string=0,
  start=0) at search.c:444

What happens next is that Emacs calls the debugger, and then your
advices kick in, starting at apply1.  And that's where the trouble
begins.

I asked why help-function-arglist is trying to read from a string, but
got no answer.

> (BTW this debug session is on the 2f67f8a commit of master (very recent, today). But the bug is present on
> emacs-25 too.)

Sorry, I see no bug yet, just a lot of ad-FOO stuff that tries to do
something silly during an error, when it should have moved out of the
way.  If there is a bug, its root cause hides inside
help-function-arglist, and the way it is called by the advices you (or
maybe it's Projectile?) have set up.  That's where we should be
looking, not in string-match-p, which did what it was supposed to do:
signaled an error when called with nil instead of a string.