Subject: bug#29326: 26.0.90; Emacs crash on running comment-dwim

From: Kaushal Modi <[email-masked]>
Date: Fri, 17 Nov 2017 18:36:32 +0000

On Fri, Nov 17, 2017 at 1:18 PM Kaushal Modi <[email-masked]> wrote:

>
> Lesson learned: "gdb ./src/emacs" is not the same as "cd src; gdb ./emacs".
>

OK, with the latest emacs-26 build, I still see the same crash (which is
good.. repeatable issue).

-->> Before proceeding, I'd like to correct myself that I am using
org-comment-dwim to reproduce this error (not comment-dwim).. well the Lisp
backtrace also tells that. <<--

Also by running the gdb in the src/ dir, the backtrace looks a bit
different (instead of SIGABRT plus putting out core dump in gdb, this time
the error is concise and code is SIG_DFL instead), but definitely more
informative.

=====
[New Thread 0x7fffed33f700 (LWP 3158)]

(emacs:3153): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup:
assertion 'source != NULL' failed

xdisp.c:2752: Emacs fatal error: assertion failed: charpos < 0 || (charpos
>= BUF_BEG (current_buffer) && charpos <= ZV)

Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=6,
backtrace_limit=2147483647) at emacs.c:364
364       signal (sig, SIG_DFL);
(gdb) bt
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at
emacs.c:364
#1  0x00000000006232d5 in die (msg=0x723428 "charpos < 0 || (charpos >=
BUF_BEG (current_buffer) && charpos <= ZV)",
    file=0x72313d "xdisp.c", line=2752) at alloc.c:7419
#2  0x0000000000449caa in init_iterator (it=0x7fffffff22e0, w=0x1593770,
charpos=1021, bytepos=1021, row=0x654be20,
    base_face_id=DEFAULT_FACE_ID) at xdisp.c:2751
#3  0x000000000044af1b in start_display (it=0x7fffffff22e0, w=0x1593770,
pos=...) at xdisp.c:3060
#4  0x00000000005f8e41 in line_number_display_width (w=0x1593770,
width=0x7fffffff365c, pixel_width=0x7fffffff3658) at indent.c:1976
#5  0x00000000005f8efa in Fline_number_display_width
(pixelwise=XIL(0xc270)) at indent.c:2007
#6  0x000000000064ab54 in funcall_subr (subr=0x9dca60
<Sline_number_display_width>, numargs=1, args=0x7fffffff37e0) at eval.c:2841
#7  0x000000000064a6ab in Ffuncall (nargs=2, args=0x7fffffff37d8) at
eval.c:2766
#8  0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0xaab99c),
vector=XIL(0xaab9bd), maxdepth=make_number(12),
    args_template=make_number(513), nargs=2, args=0x7fffffff4040) at
bytecode.c:629
#9  0x000000000064b2bd in funcall_lambda (fun=XIL(0xaab96d), nargs=2,
arg_vector=0x7fffffff4030) at eval.c:2967
#10 0x000000000064a6ef in Ffuncall (nargs=3, args=0x7fffffff4028) at
eval.c:2768
#11 0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0xaab84c),
vector=XIL(0xaab86d), maxdepth=make_number(13),
    args_template=make_number(1025), nargs=2, args=0x7fffffff4790) at
bytecode.c:629
#12 0x000000000064b2bd in funcall_lambda (fun=XIL(0xaab81d), nargs=2,
arg_vector=0x7fffffff4780) at eval.c:2967
#13 0x000000000064aef9 in apply_lambda (fun=XIL(0xaab81d),
args=XIL(0x2b90163), count=58) at eval.c:2903
#14 0x000000000064910b in eval_sub (form=XIL(0x2b90173)) at eval.c:2276
#15 0x00000000006439af in Fprogn (body=XIL(0x2b90053)) at eval.c:455
#16 0x0000000000645977 in Flet (args=XIL(0x2b90183)) at eval.c:969
#17 0x0000000000648ae4 in eval_sub (form=XIL(0x2b901d3)) at eval.c:2183
#18 0x0000000000646801 in internal_lisp_condition_case (var=XIL(0),
bodyform=XIL(0x2b901d3), handlers=XIL(0x2b90013)) at eval.c:1303
#19 0x0000000000646293 in Fcondition_case (args=XIL(0x2b901e3)) at
eval.c:1227
#20 0x0000000000648ae4 in eval_sub (form=XIL(0x2b901f3)) at eval.c:2183
#21 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#22 0x000000000064b729 in funcall_lambda (fun=XIL(0x2b8cd53), nargs=1,
arg_vector=0x0) at eval.c:3042
#23 0x000000000064aef9 in apply_lambda (fun=XIL(0x2b8cd43),
args=XIL(0x3d38dd3), count=53) at eval.c:2903
#24 0x0000000000649312 in eval_sub (form=XIL(0x3d38de3)) at eval.c:2306
#25 0x0000000000648e44 in eval_sub (form=XIL(0x3d38df3)) at eval.c:2219
#26 0x00000000006436f6 in Fif (args=XIL(0x3d381f3)) at eval.c:407
#27 0x0000000000648ae4 in eval_sub (form=XIL(0x3d381e3)) at eval.c:2183
#28 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#29 0x0000000000648ae4 in eval_sub (form=XIL(0x3d38143)) at eval.c:2183
#30 0x0000000000643754 in Fif (args=XIL(0x3d380f3)) at eval.c:410
#31 0x0000000000648ae4 in eval_sub (form=XIL(0x3d38103)) at eval.c:2183
---Type <return> to continue, or q <return> to quit---
#32 0x00000000006439af in Fprogn (body=XIL(0x28602c3)) at eval.c:455
#33 0x00000000006323d0 in Fsave_excursion (args=XIL(0x3d38063)) at
editfns.c:1050
#34 0x0000000000648ae4 in eval_sub (form=XIL(0x3d380d3)) at eval.c:2183
#35 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#36 0x0000000000645dd1 in internal_catch (tag=XIL(0x5790), func=0x64390f
<Fprogn>, arg=XIL(0x2860283)) at eval.c:1097
#37 0x0000000000645d85 in Fcatch (args=XIL(0x2860293)) at eval.c:1074
#38 0x0000000000648ae4 in eval_sub (form=XIL(0x28602a3)) at eval.c:2183
#39 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#40 0x000000000064b729 in funcall_lambda (fun=XIL(0x28601c3), nargs=1,
arg_vector=0x0) at eval.c:3042
#41 0x000000000064aef9 in apply_lambda (fun=XIL(0x28601b3),
args=XIL(0x520b603), count=44) at eval.c:2903
#42 0x0000000000649312 in eval_sub (form=XIL(0x520b613)) at eval.c:2306
#43 0x00000000006435a3 in For (args=XIL(0x5211883)) at eval.c:368
#44 0x0000000000648ae4 in eval_sub (form=XIL(0x52118a3)) at eval.c:2183
#45 0x00000000006436f6 in Fif (args=XIL(0x5211863)) at eval.c:407
#46 0x0000000000648ae4 in eval_sub (form=XIL(0x5211873)) at eval.c:2183
#47 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#48 0x0000000000645977 in Flet (args=XIL(0x52109e3)) at eval.c:969
#49 0x0000000000648ae4 in eval_sub (form=XIL(0x5210973)) at eval.c:2183
#50 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#51 0x00000000006323d0 in Fsave_excursion (args=XIL(0x52108f3)) at
editfns.c:1050
#52 0x0000000000648ae4 in eval_sub (form=XIL(0x5210963)) at eval.c:2183
#53 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#54 0x000000000064b729 in funcall_lambda (fun=XIL(0x5210763), nargs=0,
arg_vector=0x0) at eval.c:3042
#55 0x000000000064aef9 in apply_lambda (fun=XIL(0x5210733), args=XIL(0),
count=37) at eval.c:2903
#56 0x0000000000649312 in eval_sub (form=XIL(0x5210463)) at eval.c:2306
#57 0x0000000000648e44 in eval_sub (form=XIL(0x52104e3)) at eval.c:2219
#58 0x0000000000648cda in eval_sub (form=XIL(0x52105b3)) at eval.c:2197
#59 0x0000000000643c68 in Fsetq (args=XIL(0x52106a3)) at eval.c:513
#60 0x0000000000648ae4 in eval_sub (form=XIL(0x52106b3)) at eval.c:2183
#61 0x00000000006439af in Fprogn (body=XIL(0x5212d83)) at eval.c:455
#62 0x000000000064b729 in funcall_lambda (fun=XIL(0x5212c83), nargs=0,
arg_vector=0x0) at eval.c:3042
#63 0x000000000064aef9 in apply_lambda (fun=XIL(0x5212c73), args=XIL(0),
count=32) at eval.c:2903
#64 0x0000000000649312 in eval_sub (form=XIL(0x5212513)) at eval.c:2306
#65 0x0000000000643679 in Fand (args=XIL(0)) at eval.c:389
#66 0x0000000000648ae4 in eval_sub (form=XIL(0x5216d53)) at eval.c:2183
#67 0x0000000000645243 in FletX (args=XIL(0x52168f3)) at eval.c:876
#68 0x0000000000648ae4 in eval_sub (form=XIL(0x52168e3)) at eval.c:2183
#69 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#70 0x000000000064b729 in funcall_lambda (fun=XIL(0x521e7d3), nargs=1,
arg_vector=0x0) at eval.c:3042
#71 0x000000000064aef9 in apply_lambda (fun=XIL(0x521e7c3),
args=XIL(0x5208673), count=28) at eval.c:2903
#72 0x0000000000649312 in eval_sub (form=XIL(0x5208683)) at eval.c:2306
#73 0x0000000000643679 in Fand (args=XIL(0)) at eval.c:389
#74 0x0000000000648ae4 in eval_sub (form=XIL(0x520c783)) at eval.c:2183
#75 0x0000000000645243 in FletX (args=XIL(0x520c513)) at eval.c:876
#76 0x0000000000648ae4 in eval_sub (form=XIL(0x520c483)) at eval.c:2183
#77 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#78 0x00000000006323d0 in Fsave_excursion (args=XIL(0x520c213)) at
editfns.c:1050
#79 0x0000000000648ae4 in eval_sub (form=XIL(0x520c223)) at eval.c:2183
#80 0x00000000006439af in Fprogn (body=XIL(0x520c103)) at eval.c:455
#81 0x0000000000645977 in Flet (args=XIL(0x520c0d3)) at eval.c:969
#82 0x0000000000648ae4 in eval_sub (form=XIL(0x520c0c3)) at eval.c:2183
#83 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#84 0x000000000064b729 in funcall_lambda (fun=XIL(0x520bf53), nargs=1,
arg_vector=0x0) at eval.c:3042
#85 0x000000000064aef9 in apply_lambda (fun=XIL(0x520bf03),
args=XIL(0x520bc13), count=20) at eval.c:2903
#86 0x0000000000649312 in eval_sub (form=XIL(0x520bd33)) at eval.c:2306
#87 0x00000000006439af in Fprogn (body=XIL(0)) at eval.c:455
#88 0x000000000064b729 in funcall_lambda (fun=XIL(0x520b833), nargs=0,
arg_vector=0x0) at eval.c:3042
#89 0x000000000064a7f1 in Ffuncall (nargs=1, args=0x7fffffff8648) at
eval.c:2780
#90 0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0xad4a14),
vector=XIL(0xad4a35), maxdepth=make_number(3),
args_template=make_number(0), nargs=0, args=0x7fffffff8da0) at
bytecode.c:629
#91 0x000000000064b2bd in funcall_lambda (fun=XIL(0xad49d5), nargs=0,
arg_vector=0x7fffffff8da0) at eval.c:2967
#92 0x000000000064a6ef in Ffuncall (nargs=1, args=0x7fffffff8d98) at
eval.c:2768
#93 0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0xb41b5c),
vector=XIL(0xb41b7d), maxdepth=make_number(5),
args_template=make_number(257), nargs=1, args=0x7fffffff9648) at
bytecode.c:629
#94 0x000000000064b2bd in funcall_lambda (fun=XIL(0xb41b1d), nargs=1,
arg_vector=0x7fffffff9640) at eval.c:2967
---Type <return> to continue, or q <return> to quit---
#95 0x000000000064a6ef in Ffuncall (nargs=2, args=0x7fffffff9638) at
eval.c:2768
#96 0x00000000006403df in Ffuncall_interactively (nargs=2,
args=0x7fffffff9638) at callint.c:252
#97 0x000000000064aa62 in funcall_subr (subr=0xd84260
<Sfuncall_interactively>, numargs=2, args=0x7fffffff9638) at eval.c:2821
#98 0x000000000064a6ab in Ffuncall (nargs=3, args=0x7fffffff9630) at
eval.c:2766
#99 0x0000000000642951 in Fcall_interactively (function=XIL(0x43c240),
record_flag=XIL(0), keys=XIL(0x7235985)) at callint.c:841
#100 0x000000000064aba1 in funcall_subr (subr=0xd842a0
<Scall_interactively>, numargs=1, args=0x7fffffff9af8) at eval.c:2846
#101 0x000000000064a6ab in Ffuncall (nargs=2, args=0x7fffffff9af0) at
eval.c:2766
#102 0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0x6631ff4),
vector=XIL(0x6632775), maxdepth=make_number(3),
args_template=make_number(257), nargs=1, args=0x7fffffffa368) at
bytecode.c:629
#103 0x000000000064b2bd in funcall_lambda (fun=XIL(0x66327c5), nargs=1,
arg_vector=0x7fffffffa360) at eval.c:2967
#104 0x000000000064a6ef in Ffuncall (nargs=2, args=0x7fffffffa358) at
eval.c:2768
#105 0x00000000006403df in Ffuncall_interactively (nargs=2,
args=0x7fffffffa358) at callint.c:252
#106 0x000000000064aa62 in funcall_subr (subr=0xd84260
<Sfuncall_interactively>, numargs=2, args=0x7fffffffa358) at eval.c:2821
#107 0x000000000064a6ab in Ffuncall (nargs=3, args=0x7fffffffa350) at
eval.c:2766
#108 0x0000000000642951 in Fcall_interactively (function=XIL(0x57f97a0),
record_flag=XIL(0), keys=XIL(0x7235985)) at callint.c:841
#109 0x000000000064aba1 in funcall_subr (subr=0xd842a0
<Scall_interactively>, numargs=3, args=0x7fffffffa840) at eval.c:2846
#110 0x000000000064a6ab in Ffuncall (nargs=4, args=0x7fffffffa838) at
eval.c:2766
#111 0x000000000069f6c7 in exec_byte_code (bytestr=XIL(0xaa1dac),
vector=XIL(0xaa1dcd), maxdepth=make_number(13),
args_template=make_number(1025), nargs=1, args=0x7fffffffb030) at
bytecode.c:629
#112 0x000000000064b2bd in funcall_lambda (fun=XIL(0xaa1d7d), nargs=1,
arg_vector=0x7fffffffb028) at eval.c:2967
#113 0x000000000064a6ef in Ffuncall (nargs=2, args=0x7fffffffb020) at
eval.c:2768
#114 0x0000000000649fa8 in call1 (fn=XIL(0x3f00), arg1=XIL(0x57f97a0)) at
eval.c:2617
#115 0x0000000000591dad in command_loop_1 () at keyboard.c:1482
#116 0x000000000064689d in internal_condition_case (bfun=0x5915d0
<command_loop_1>, handlers=XIL(0x5250), hfun=0x590c26 <cmd_error>) at
eval.c:1332
#117 0x00000000005911d5 in command_loop_2 (ignore=XIL(0)) at keyboard.c:1110
#118 0x0000000000645dd1 in internal_catch (tag=XIL(0xc8d0), func=0x5911ac
<command_loop_2>, arg=XIL(0)) at eval.c:1097
#119 0x0000000000591177 in command_loop () at keyboard.c:1089
#120 0x000000000059073b in recursive_edit_1 () at keyboard.c:695
#121 0x000000000059091a in Frecursive_edit () at keyboard.c:766
#122 0x000000000058e617 in main (argc=1, argv=0x7fffffffb528) at
emacs.c:1713

Lisp Backtrace:
"line-number-display-width" (0xffff37e0)
"line-move-visual" (0xffff4030)
"line-move" (0xffff4780)
"let" (0xffff4b80)
"condition-case" (0xffff4e70)
"nim-line-move" (0xffff5030)
"not" (0xffff5300)
"if" (0xffff54a0)
"progn" (0xffff5640)
"if" (0xffff57e0)
"save-excursion" (0xffff59c0)
"catch" (0xffff5be0)
"nim-line-empty-p" (0xffff5da0)
"or" (0xffff60c0)
"if" (0xffff6260)
"let" (0xffff64f0)
"save-excursion" (0xffff66d0)
"nim-get-empty-line-indent" (0xffff6890)
"cons" (0xffff6b50)
"list" (0xffff6ce0)
"setq" (0xffff6ed0)
"nim-smie-indent-calculate" (0xffff7090)
"and" (0xffff73a0)
"let*" (0xffff7590)
"nim-indent-calculate-indentation" (0xffff7750)
"and" (0xffff7a70)
"let*" (0xffff7c60)
"save-excursion" (0xffff7e40)
"let" (0xffff80d0)
"nim--indent-line-core" (0xffff8290)
"nim-indent-line" (0xffff8650)
"indent-according-to-mode" (0xffff8da0)
"comment-dwim" (0xffff9640)
---Type <return> to continue, or q <return> to quit---
"funcall-interactively" (0xffff9638)
"call-interactively" (0xffff9af8)
"org-comment-dwim" (0xffffa360)
"funcall-interactively" (0xffffa358)
"call-interactively" (0xffffa840)
"command-execute" (0xffffb028)
=====

This time, frame#2 looks same as frame#3 in the earlier backtrace, so
here's the same info for f 2.. and the values are the same:

(gdb) f 2
#2  0x0000000000449caa in init_iterator (it=0x7fffffff22e0, w=0x1593770,
charpos=1021, bytepos=1021, row=0x654be20, base_face_id=DEFAULT_FACE_ID) at
xdisp.c:2751
2751      eassert (charpos < 0 || (charpos >= BUF_BEG (current_buffer)
(gdb) p ZV
$1 = 263
(gdb) p Z
$2 = 263
(gdb)

It might be evident from the Lisp backtrace, but I have the native line
numbers enabled for nim-mode, but disabled for org.

Org is displaying the nim-mode buffers in org-mode, but does something like
enabling the code block's major mode only for that code snippet to do
indentation, commenting etc. (the native line number enabling would be a
part of that I believe).

-- 

Kaushal Modi