Subject: bug#3286: NS hang in event handling

From: David Reitter <[email-masked]>
Date: Wed, 13 May 2009 23:17:43 -0700

I can reproduce a hang (C-g doesn't work) pretty reliably in a current  
build (NS port, on OS X 10.5.7) using this recipe:

[Prerequisite: ESS must be installed]

Emacs -q  (actually, Aquamacs)

Evaluate the bit of code shown at the bottom of this e-mail

C-x b test-buffer RET
M-x R-mode RET
M-x R RET  ;; to open an R process

then switch back to test-buffer and start typing randomly.  I don't  
need to type much to reproduce this.
Emacs wil hang and not react to anything except changing faces when  
the mouse cursor is moved over text with `mouse-face' properties.

I don't get this if I simplify `ess-maybe-show-arg-list' to just show  
a message.

If you want me to do something specific with gdb, then I can do that  
of course.

(defvar ess-arglist-show-timer nil)
(progn
   (if ess-arglist-show-timer
       (cancel-timer ess-arglist-show-timer))
   (setq ess-arglist-show-timer
	(run-with-idle-timer 0.2 t
			     (defun ess-maybe-show-arg-list ()
			       (interactive)
			       (and (eq major-mode 'ess-mode)
				    (or (not (current-message))
					(and (equal ess-r-args-show-as 'tooltip)
					     ess-has-tooltip))
				    ;; to do check tooltip
				    (condition-case nil
					(ess-r-args-show)
				      ;; avoid showing error if not over function
				      (error nil)))))))

(defun ess-r-args-current-function ()
   "Returns the name of the R function assuming point is currently
within the argument list or nil if no possible function name is
found."
   (save-excursion
     (condition-case nil (up-list -1)
       (error "Can't find opening parenthesis."))
     (let ((posend (point)))
       (backward-sexp 1)
       (let ((rfunname (buffer-substring-no-properties posend (point))))
	(if (posix-string-match "^[a-zA-Z0-9_\.]+$" rfunname)
	    rfunname nil)))))

from ESS:

#0  0x9021e286 in mach_msg_trap ()
#1  0x90225a7c in mach_msg ()
#2  0x9012a04e in CFRunLoopRunSpecific ()
#3  0x9012ac78 in CFRunLoopRunInMode ()
#4  0x9272b28c in RunCurrentEventLoopInMode ()
#5  0x9272b0a5 in ReceiveNextEventCommon ()
#6  0x9272af19 in BlockUntilNextEventMatchingListInMode ()
#7  0x93f15d0d in _DPSNextEvent ()
#8  0x93f155c0 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#9  0x93f0e5fb in -[NSApplication run] ()
#10 0x001a6083 in ns_read_socket ()
#11 0x000c0a41 in read_avail_input ()
#12 0x000c0bb5 in gobble_input ()
#13 0x001a6454 in ns_select ()
#14 0x00185c02 in wait_reading_process_output ()
#15 0x00187198 in Faccept_process_output ()
#16 0x0013d750 in Ffuncall ()
#17 0x0017e10a in Fbyte_code ()
#18 0x0013cfa4 in funcall_lambda ()
#19 0x0013d4ab in Ffuncall ()
#20 0x0017e10a in Fbyte_code ()
#21 0x0013cfa4 in funcall_lambda ()
#22 0x0013d4ab in Ffuncall ()
#23 0x0017e10a in Fbyte_code ()
#24 0x0013cfa4 in funcall_lambda ()
#25 0x0013d4ab in Ffuncall ()
#26 0x0017e10a in Fbyte_code ()
#27 0x0013cfa4 in funcall_lambda ()
#28 0x001402f9 in apply_lambda ()
#29 0x0013fea2 in Feval ()
#30 0x001415b2 in internal_lisp_condition_case ()
#31 0x0014163b in Fcondition_case ()
#32 0x001401a8 in Feval ()
#33 0x00140b5f in Fand ()
#34 0x001401a8 in Feval ()
#35 0x0013d1b1 in funcall_lambda ()
#36 0x0013d4ab in Ffuncall ()
#37 0x0013e0a0 in Fapply ()
#38 0x0013d6a6 in Ffuncall ()
#39 0x0017e10a in Fbyte_code ()
#40 0x00140146 in Feval ()
#41 0x001415b2 in internal_lisp_condition_case ()
#42 0x0017eb1e in Fbyte_code ()
#43 0x0013cfa4 in funcall_lambda ()
#44 0x0013d4ab in Ffuncall ()
#45 0x0013db39 in call1 ()
#46 0x000b8aea in timer_check ()
#47 0x000c1858 in detect_input_pending_run_timers ()
#48 0x00185cd1 in wait_reading_process_output ()
#49 0x00004226 in sit_for ()
#50 0x000c761d in read_char ()
#51 0x000c9133 in read_key_sequence ()
#52 0x000cb4b0 in command_loop_1 ()
#53 0x0013baad in internal_condition_case ()
#54 0x000b77b8 in command_loop_2 ()
#55 0x0013b98c in internal_catch ()
#56 0x000be29b in recursive_edit_1 ()
#57 0x000be454 in Frecursive_edit ()
#58 0x000b691b in main ()