Subject: 24.5; ask-user-about-supersession-threat causes emacs -batch to hang
From: Richard Sharman <[email-masked]>
To: "[email-masked]" <[email-masked]>
Cc: Richard Sharman <[email-masked]>
Date: Wed, 10 Feb 2016 18:27:30 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

I'm not sure if this is a bug or not.

When running emacs -batch, if a function modifies a buffer and calls
save-buffer and there is another emacs -batch also updating the same
file, one of them can call ask-user-about-supersession-threat [in
userlock.el].

This causes the emacs process to hang because read-char-choice never
returns.  See traceback below.

This happened when running make -j 6 and I changed the scenario to not
happen, but I wondered if ask-user-about-supersession-threat should be
act upon variable noninteractive.

Perhaps one is supposed to supply a replacement for
ask-user-about-supersession-threat if running emacs in batch mode?

--- Traceback ---
This was obtained by attaching with gdb to the emacs process.

(gdb) bt
#0  0x000000379fae165e in pselect () from /lib64/libc.so.6
#1  0x00000000005bdf02 in xg_select (fds_lim=6, rfds=rfds@entry=0x7fff9903b8a0, wfds=0x7fff9903b920, efds=efds@entry=0x0, timeout=timeout@entry=0x7fff9903b890,
    sigmask=sigmask@entry=0x0) at ../../src/xgselect.c:114
#2  0x000000000058a9c3 in wait_reading_process_output (time_limit=time_limit@entry=0, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=true,
    wait_for_cell=wait_for_cell@entry=12186482, wait_proc=wait_proc@entry=0x0, just_wait_proc=just_wait_proc@entry=0) at ../../src/process.c:4606
#3  0x00000000004e38f7 in kbd_buffer_get_event (end_time=0x0, used_mouse_menu=<optimized out>, kbp=<synthetic pointer>) at ../../src/keyboard.c:3907
#4  read_event_from_main_queue (used_mouse_menu=<optimized out>, local_getcjmp=<optimized out>, end_time=0x0) at ../../src/keyboard.c:2247
#5  read_decoded_event_from_main_queue (end_time=end_time@entry=0x0, local_getcjmp=local_getcjmp@entry=0x7fff9903be10, prev_event=prev_event@entry=12186482,
    used_mouse_menu=used_mouse_menu@entry=0x7fff9903c09b) at ../../src/keyboard.c:2310
#6  0x00000000004e7b3c in read_char (commandflag=0, map=map@entry=15139126, prev_event=12186482, used_mouse_menu=used_mouse_menu@entry=0x7fff9903c09b, end_time=end_time@entry=0x0)
    at ../../src/keyboard.c:2896
#7  0x00000000004e890f in read_key_sequence (keybuf=keybuf@entry=0x7fff9903c150, prompt=prompt@entry=14531377, dont_downcase_last=<optimized out>, can_return_switch_frame=false,
    fix_current_buffer=fix_current_buffer@entry=false, prevent_redisplay=prevent_redisplay@entry=false, bufsize=30) at ../../src/keyboard.c:9089
#8  0x00000000004ea140 in read_key_sequence_vs (prompt=14531377, continue_echo=12186482, dont_downcase_last=12186530, can_return_switch_frame=12186482, cmd_loop=<optimized out>,
    allow_string=<optimized out>) at ../../src/keyboard.c:9784
#9  0x000000000054d1b4 in Ffuncall (nargs=<optimized out>, args=<optimized out>) at ../../src/eval.c:2827
#10 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=0, nargs=0, args=0x4) at ../../src/bytecode.c:916
#11 0x000000000054cd47 in funcall_lambda (fun=8852921, nargs=nargs@entry=0, arg_vector=0x1070e60, arg_vector@entry=0x7fff9903c458) at ../../src/eval.c:2978
#12 0x000000000054d013 in Ffuncall (nargs=1, args=0x7fff9903c450) at ../../src/eval.c:2872
#13 0x000000000054c8de in eval_sub (form=form@entry=15139174) at ../../src/eval.c:2154
#14 0x000000000054b56b in internal_catch (tag=15676322, func=0x54c220 <eval_sub>, arg=15139174) at ../../src/eval.c:1112
#15 0x0000000000581be8 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=1024, nargs=140735760549240, args=0x8d)
    at ../../src/bytecode.c:1097
#16 0x000000000054cd47 in funcall_lambda (fun=8852409, nargs=nargs@entry=1, arg_vector=0x8713e0 <pure+120224>, arg_vector@entry=0x7fff9903c718) at ../../src/eval.c:2978
#17 0x000000000054d013 in Ffuncall (nargs=2, args=0x7fff9903c710) at ../../src/eval.c:2872
#18 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=3080, nargs=140735760549640, args=0x2)
    at ../../src/bytecode.c:916
#19 0x000000000054cd47 in funcall_lambda (fun=8854969, nargs=nargs@entry=2, arg_vector=0x871de0 <pure+122784>, arg_vector@entry=0x7fff9903c850) at ../../src/eval.c:2978
#20 0x000000000054d013 in Ffuncall (nargs=3, args=0x7fff9903c848) at ../../src/eval.c:2872
#21 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=12186482, nargs=140735760549952, args=0x3)
    at ../../src/bytecode.c:916
#22 0x000000000054ccaf in funcall_lambda (fun=19838589, nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fff9903c9d8) at ../../src/eval.c:3044
#23 0x000000000054d013 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fff9903c9d0) at ../../src/eval.c:2872
#24 0x000000000054d34a in call1 (fn=<optimized out>, arg1=arg1@entry=14349665) at ../../src/eval.c:2610
#25 0x00000000005019b5 in lock_file (fn=14349665) at ../../src/filelock.c:713
#26 0x0000000000503115 in prepare_to_modify_buffer_1 (start=start@entry=16700, end=end@entry=16700, preserve_ptr=preserve_ptr@entry=0x0) at ../../src/insdel.c:1812
#27 0x0000000000503621 in prepare_to_modify_buffer (start=16700, end=16700, preserve_ptr=preserve_ptr@entry=0x0) at ../../src/insdel.c:1847
#28 0x00000000005038d5 in insert_from_string_1 (string=14413089, pos=0, pos_byte=0, nchars=35, nbytes=35, inherit=<optimized out>, before_markers=before_markers@entry=false)
    at ../../src/insdel.c:893
#29 0x0000000000504130 in insert_from_string (string=<optimized out>, pos=<optimized out>, pos_byte=<optimized out>, length=<optimized out>, length_byte=<optimized out>,
    inherit=<optimized out>) at ../../src/insdel.c:842
#30 0x00000000005417a3 in general_insert_function (insert_func=0x503e40 <insert>, insert_from_string_func=0x504100 <insert_from_string>, inherit=inherit@entry=false, nargs=1,
    args=0x7fff9903ec40) at ../../src/editfns.c:2248
#31 0x00000000005418ab in Finsert (nargs=<optimized out>, args=<optimized out>) at ../../src/editfns.c:2289
#32 0x000000000054c8de in eval_sub (form=<optimized out>) at ../../src/eval.c:2154
#33 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#34 0x000000000054f5f5 in Flet (args=19476358) at ../../src/eval.c:970
#35 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#36 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#37 0x000000000054cdac in funcall_lambda (fun=fun@entry=19476262, nargs=nargs@entry=4, arg_vector=arg_vector@entry=0x7fff9903eee0) at ../../src/eval.c:3037
#38 0x000000000054c178 in apply_lambda (fun=19476262, args=<optimized out>, count=count@entry=42) at ../../src/eval.c:2919
#39 0x000000000054c4e9 in eval_sub (form=<optimized out>) at ../../src/eval.c:2256
#40 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#41 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#42 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#43 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#44 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#45 0x000000000054ca15 in Fprogn (body=6, body@entry=19494038) at ../../src/eval.c:462
#46 0x000000000054f688 in Fwhile (args=<optimized out>) at ../../src/eval.c:992
#47 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#48 0x000000000054ca15 in Fprogn (body=6, body@entry=19518774) at ../../src/eval.c:462
#49 0x0000000000548745 in Fsave_restriction (body=19518774) at ../../src/editfns.c:3415
#50 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#51 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#52 0x000000000054f5f5 in Flet (args=19518230) at ../../src/eval.c:970
#53 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#54 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#55 0x000000000054cdac in funcall_lambda (fun=fun@entry=19518182, nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fff9903f690) at ../../src/eval.c:3037
#56 0x000000000054c178 in apply_lambda (fun=19518182, args=<optimized out>, count=count@entry=22) at ../../src/eval.c:2919
#57 0x000000000054c4e9 in eval_sub (form=<optimized out>) at ../../src/eval.c:2256
#58 0x000000000054ca15 in Fprogn (body=6, body@entry=19515958) at ../../src/eval.c:462
#59 0x000000000054f688 in Fwhile (args=<optimized out>) at ../../src/eval.c:992
#60 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#61 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#62 0x000000000054f5f5 in Flet (args=19516310) at ../../src/eval.c:970
#63 0x000000000054c7e3 in eval_sub (form=<optimized out>) at ../../src/eval.c:2131
#64 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#65 0x000000000054cdac in funcall_lambda (fun=fun@entry=19513158, nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fff9903fab0) at ../../src/eval.c:3037
#66 0x000000000054c178 in apply_lambda (fun=19513158, args=<optimized out>, count=count@entry=14) at ../../src/eval.c:2919
#67 0x000000000054c4e9 in eval_sub (form=<optimized out>) at ../../src/eval.c:2256
#68 0x000000000054ca15 in Fprogn (body=6) at ../../src/eval.c:462
#69 0x000000000054cdac in funcall_lambda (fun=fun@entry=19509782, nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fff9903fc80) at ../../src/eval.c:3037
#70 0x000000000054c178 in apply_lambda (fun=19509782, args=<optimized out>, count=count@entry=11) at ../../src/eval.c:2919
#71 0x000000000054c4e9 in eval_sub (form=form@entry=19527974) at ../../src/eval.c:2256
#72 0x000000000054fae1 in Feval (form=19527974, lexical=<optimized out>) at ../../src/eval.c:1996
#73 0x000000000054d1f0 in Ffuncall (nargs=<optimized out>, args=<optimized out>) at ../../src/eval.c:2814
#74 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=1028, nargs=77, args=0x2) at ../../src/bytecode.c:916
#75 0x000000000054cd47 in funcall_lambda (fun=9325745, nargs=nargs@entry=1, arg_vector=0x8e4cd8 <pure+593560>, arg_vector@entry=0x7fff99040030) at ../../src/eval.c:2978
#76 0x000000000054d013 in Ffuncall (nargs=2, args=0x7fff99040028) at ../../src/eval.c:2872
#77 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=0, nargs=140735760564264, args=0x2)
    at ../../src/bytecode.c:916
#78 0x000000000054cd47 in funcall_lambda (fun=9300361, nargs=nargs@entry=0, arg_vector=0x8de9b0 <pure+568176>, arg_vector@entry=0x7fff990401b8) at ../../src/eval.c:2978
#79 0x000000000054d013 in Ffuncall (nargs=1, args=0x7fff990401b0) at ../../src/eval.c:2872
#80 0x0000000000580de5 in exec_byte_code (bytestr=-514, vector=140735760544464, maxdepth=140735760544592, args_template=0, nargs=140735760564648, args=0x1)
    at ../../src/bytecode.c:916
#81 0x000000000054cd47 in funcall_lambda (fun=9296881, fun@entry=9296837, nargs=nargs@entry=0, arg_vector=0x8ddc18 <pure+564696>, arg_vector@entry=0x7fff990402a0)
    at ../../src/eval.c:2978
#82 0x000000000054c178 in apply_lambda (fun=9296837, args=<optimized out>, count=count@entry=3) at ../../src/eval.c:2919
#83 0x000000000054c4e9 in eval_sub (form=form@entry=15729862) at ../../src/eval.c:2256
#84 0x000000000054fae1 in Feval (form=15729862, lexical=<optimized out>) at ../../src/eval.c:1996
#85 0x000000000054b65e in internal_condition_case (bfun=bfun@entry=0x4dcb80 <top_level_2>, handlers=<optimized out>, hfun=hfun@entry=0x4e13c0 <cmd_error>) at ../../src/eval.c:1348
#86 0x00000000004dcb66 in top_level_1 (ignore=ignore@entry=12186482) at ../../src/keyboard.c:1195
#87 0x000000000054b56b in internal_catch (tag=12233698, func=func@entry=0x4dcb00 <top_level_1>, arg=12186482) at ../../src/eval.c:1112
#88 0x00000000004e0fcf in command_loop () at ../../src/keyboard.c:1156
#89 recursive_edit_1 () at ../../src/keyboard.c:778
#90 0x00000000004e12fd in Frecursive_edit () at ../../src/keyboard.c:849
#91 0x0000000000413755 in main (argc=<optimized out>, argv=0x7fff99040628) at ../../src/emacs.c:1642
(gdb)

In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
 of 2015-04-27 on sharmanbox.mitel.com
Windowing system distributor `CentOS', version 11.0.11300000
System Description: Red Hat Enterprise Linux Server release 6

Configured using:
 `configure --with-x-toolkit=athena --without-gsettings'

Important settings:
  value of $LANG: C
  value of $XMODIFIERS: @im=none
  locale-coding-system: nil

(Since this is not the emacs session that produced the problem the rest
of the generated input from rerprt-emacs-bug has been removed.)

I apologize for anything that occurs after this line; it's out of my control!

________________________________
NOTE: This e-mail (including any attachments) is for the sole use of the intended recipient(s) and may contain information that is confidential and/or protected by legal privilege. Any unauthorized review, use, copy, disclosure or distribution of this e-mail is strictly prohibited. If you are not the intended recipient, please notify Mitel immediately and destroy all copies of this e-mail. Mitel does not accept any liability for breach of security, error or virus that may result from the transmission of this message.