Subject: bug#29031: 25.3; Segmentation fault when starting emacs with my config

From: Kaushal Modi <[email-masked]>
Date: Mon, 30 Oct 2017 16:03:43 +0000

Hello all,

I cannot understand why, but reverting nlinum to version 1.7 fixed this.

stable nlinum version for me:
http://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?id=e885224c70f5fc03b23590304dd0fd21524d27e1

Also I couldn't figure out how to reproduce this issue on emacs -Q. But
here are some observations (on emacs 25.3):

- I started this bug saying that I can reproduce this crash only on the
company CAD built emacs 25.3. But turns out that the crash happens on my
build of emacs-25 branch that I had done a long time back, only when
running emacs, not emacsclient.

- Crash happened only when I loaded nlinum (not linum) AND had my config
call the below modi/blend-linum function in wrapper function in
window-setup-hook.
- Couldn't recreate crash if I commented out the lines calling that
function, *or* the lines loading nlinum in my config.
- Even if I commented out the call to modi/blend-linum, emacs 25.3 does not
crash, but the line numbers look BAD (see this gifv to see what I mean:
https://i.imgur.com/8npahiz.gifv). That is with current line number
highlight enabled in nlinum.
- The crash AND visual artifact issue went away on reverted to nlinum 1.7
without having to comment out the call to modi/blend-linum, on emacs 25.3.

=====
(defun modi/blend-linum ()
  "Set the linum foreground face to that of
`font-lock-comment-face' and background color to that of the
theme."
  (interactive)
  (set-face-attribute
   'linum nil
   :height 0.9
   :foreground (if (string= (face-foreground 'font-lock-comment-face)
"unspecified-fg")
                   "#8f8f8f"
                 (face-foreground 'font-lock-comment-face))
   :background (if (string= (face-background 'default) "unspecified-bg")
                   "#282828"
                 (face-background 'default))))
=====

**I couldn't reproduce the visual artifact issues or crash on emacs 26.x+.**

Appendix: I generate my theme-loading function 'load-theme/smyx' (that
loads my custom theme smyx). That is the wrapper fn I referred above,
that's called in window-setup-hook. That wrapper fn calls modi/blend-linum.
Relevant part from my config[1].

[1]:
https://github.com/kaushalmodi/.emacs.d/blob/1e37e3502ed1337420d7fb0db7f940c52694bdca/setup-files/setup-visual.el#L157-L221

On Mon, Oct 30, 2017 at 10:17 AM Kaushal Modi <[email-masked]>
wrote:

> The CAD department built 25.3 again, this time, with libotf. But I still
> get the segmentation fault. See the backtrace below. The backtrace looks
> different this time though.. "xdisp.c: No such file or directory"!?
>
> Emacs version: GNU Emacs 25.3.1 (x86_64-unknown-linux-gnu, GTK+ Version
> 2.24.23)
>  of 2017-10-30, built using commit .
>
> ./configure options:
>   --prefix=/cad/adi/apps/gnu/linux/x86_64/6/local/emacs/25.3 --with-modules
>
> Features:
>   XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GCONF NOTIFY ACL LIBSELINUX GNUTLS
> LIBXML2 FREETYPE LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK2 X11 MODULES
>
>
> =====
>
> Starting program:
> /cad/adi/apps/gnu/linux/x86_64/6/local/emacs/25.3/bin/emacs
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> [New Thread 0x7fffef071700 (LWP 10664)]
>
> Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
> 0x000000000043d101 in append_glyph (it=0x7fffffff2390) at xdisp.c:25880
> 25880   xdisp.c: No such file or directory.
> (gdb) bt
> #0  0x000000000043d101 in append_glyph (it=0x7fffffff2390) at xdisp.c:25880
> #1  x_produce_glyphs (it=0x7fffffff2390) at xdisp.c:27175
> #2  0x0000000000452032 in display_line (it=0x7fffffff2390) at xdisp.c:20676
> #3  0x0000000000457868 in try_window (window=18793157, pos=..., flags=1)
> at xdisp.c:17251
> #4  0x0000000000460e41 in redisplay_window (window=18793157,
> just_this_one_p=false)
>     at xdisp.c:16700
> #5  0x0000000000463b36 in redisplay_window_0 (window=<optimized out>) at
> xdisp.c:14491
> #6  0x000000000055e7c6 in internal_condition_case_1 (bfun=0x463b10
> <redisplay_window_0>,
>     arg=18793157, handlers=<optimized out>, hfun=0x429b40
> <redisplay_window_error>)
>     at eval.c:1339
> #7  0x000000000044612e in redisplay_windows (window=<optimized out>) at
> xdisp.c:14471
> #8  0x000000000045cfd5 in redisplay_internal () at xdisp.c:14031
> #9  0x00000000004f5299 in read_char (commandflag=1, map=109811619,
> prev_event=0,
>     used_mouse_menu=0x7fffffffb11f, end_time=0x0) at keyboard.c:2482
> #10 0x00000000004f90c0 in read_key_sequence (keybuf=0x7fffffffb190,
> prompt=0,
>     dont_downcase_last=false, can_return_switch_frame=true,
> fix_current_buffer=true,
>     prevent_redisplay=false, bufsize=30) at keyboard.c:9068
> #11 0x00000000004fa3ba in command_loop_1 () at keyboard.c:1370
> #12 0x000000000055e82a in internal_condition_case (bfun=0x4fa1f0
> <command_loop_1>,
>     handlers=<optimized out>, hfun=0x4f8200 <cmd_error>) at eval.c:1315
> #13 0x00000000004f81ec in command_loop_2 (ignore=<optimized out>) at
> keyboard.c:1112
> #14 0x000000000055e8b8 in internal_catch (tag=<optimized out>,
>     func=0x4f81d0 <command_loop_2>, arg=0) at eval.c:1080
> #15 0x00000000004f7f67 in command_loop () at keyboard.c:1091
> #16 0x00000000004f7ff5 in recursive_edit_1 () at keyboard.c:697
> #17 0x00000000004f8135 in Frecursive_edit () at keyboard.c:768
> #18 0x00000000004e997e in main (argc=<optimized out>, argv=<optimized
> out>) at emacs.c:1629
>
> --
>
> Kaushal Modi
>
-- 

Kaushal Modi