Subject: Re: bug#18848: hang is in [EmacsApp run] (24.4.51; Hang after toolbar use)

From: "Jan D." <[email-masked]>
Date: Sat, 8 Nov 2014 18:19:00 +0100

Hello.

> 8 nov 2014 kl. 18:06 skrev David Reitter <[email-masked]>:
> 
> Your change does not help.
> I think it’s a Yosemite bug.  Below is a workaround.

This code does not get executed on Yosemite with the latest changes.

	Jan D.

> 
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -4748,11 +4766,18 @@ ns_term_shutdown (int sig)
>         [pool release];
>         pool = [[NSAutoreleasePool alloc] init];
> 
> +       /* OSX 10.10.1 seems to swallow AppDefined events when
> +          other events are put in the queue in rapid succession.
> +          To prevent Emacs becoming unresponsive, we need to
> +          set a reasonable timeout. */
>         NSEvent *event =
>           [self nextEventMatchingMask:NSAnyEventMask
> -                            untilDate:[NSDate distantFuture]
> +                            untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]
>                                inMode:NSDefaultRunLoopMode
>                               dequeue:YES];
> +       if (event == nil) // timeout
> +         { shouldKeepRunning = NO;}
> +       else
>         [self sendEvent:event];
>         [self updateWindows];
>     } while (shouldKeepRunning);
> 
> 
>> On Nov 8, 2014, at 11:34 AM, Jan D. <[email-masked]> wrote:
>> 
>> I can't reproduce this, but made some changes, please try it.
>> 
>> 	Jan D.
>> 
>>> 29 okt 2014 kl. 14:47 skrev David Reitter <[email-masked]>:
>>> 
>>> This occurs in OS X 10.10 “Yosemite”, but not earlier.
>>> 
>>> events on the NS side are received and put into the emacs event queue.  
>>> 
>>> Attaching full call stack below for reference.
>>> 
>>> * frame #0: 0x00007fff909a952e libsystem_kernel.dylib`mach_msg_trap + 10
>>>  frame #1: 0x00007fff909a869f libsystem_kernel.dylib`mach_msg + 55
>>>  frame #2: 0x00007fff8598db14 CoreFoundation`__CFRunLoopServiceMachPort + 212
>>>  frame #3: 0x00007fff8598cfdb CoreFoundation`__CFRunLoopRun + 1371
>>>  frame #4: 0x00007fff8598c838 CoreFoundation`CFRunLoopRunSpecific + 296
>>>  frame #5: 0x00007fff919f943f HIToolbox`RunCurrentEventLoopInMode + 235
>>>  frame #6: 0x00007fff919f91ba HIToolbox`ReceiveNextEventCommon + 431
>>>  frame #7: 0x00007fff919f8ffb HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
>>>  frame #8: 0x00007fff89ca8821 AppKit`_DPSNextEvent + 964
>>>  frame #9: 0x00007fff89ca7fd0 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
>>>  frame #10: 0x00000001002b2e8b Emacs`-[EmacsApp run](self=0x0000000101420b20, _cmd=0x00007fff8a607034) + 379 at nsterm.m:4497
>>>  frame #11: 0x00000001002c4ce7 Emacs`ns_read_socket(terminal=0x0000000102823678, hold_quit=0x00007fff5fbfbfa0) + 855 at nsterm.m:3641
>>>  frame #12: 0x0000000100145c6d Emacs`gobble_input + 173 at keyboard.c:6850
>>>  frame #13: 0x000000010014be85 Emacs`get_input_pending(flags=3) + 117 at keyboard.c:6771
>>>  frame #14: 0x0000000100150c5d Emacs`Finput_pending_p(check_timers=4345311338) + 173 at keyboard.c:9940
>>>  frame #15: 0x0000000100201d44 Emacs`Ffuncall(nargs=2, args=0x00007fff5fbfc130) + 1044 at eval.c:2812
>>>  frame #16: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4298564145, vector=4298564181, maxdepth=28, args_template=3076, nargs=1, args=0x00007fff5fbfc838) + 3504 at bytecode.c:916
>>>  frame #17: 0x0000000100202e84 Emacs`funcall_lambda(fun=4298564101, nargs=1, arg_vector=0x00007fff5fbfc830) + 500 at eval.c:2979
>>>  frame #18: 0x0000000100201f6c Emacs`Ffuncall(nargs=2, args=0x00007fff5fbfc828) + 1596 at eval.c:2861
>>>  frame #19: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4299852505, vector=4299852541, maxdepth=16, args_template=4345311290, nargs=0, args=0x0000000000000000) + 3504 at bytecode.c:916
>>>  frame #20: 0x0000000100203261 Emacs`funcall_lambda(fun=4299852461, nargs=0, arg_vector=0x00007fff5fbfcf30) + 1489 at eval.c:3045
>>>  frame #21: 0x0000000100201f6c Emacs`Ffuncall(nargs=1, args=0x00007fff5fbfcf28) + 1596 at eval.c:2861
>>>  frame #22: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4299813801, vector=4299813837, maxdepth=20, args_template=4345311290, nargs=0, args=0x0000000000000000) + 3504 at bytecode.c:916
>>>  frame #23: 0x0000000100203261 Emacs`funcall_lambda(fun=4299813757, nargs=0, arg_vector=0x00007fff5fbfd630) + 1489 at eval.c:3045
>>>  frame #24: 0x0000000100201f6c Emacs`Ffuncall(nargs=1, args=0x00007fff5fbfd628) + 1596 at eval.c:2861
>>>  frame #25: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4299812881, vector=4299812917, maxdepth=16, args_template=4345311290, nargs=0, args=0x0000000000000000) + 3504 at bytecode.c:916
>>>  frame #26: 0x0000000100203261 Emacs`funcall_lambda(fun=4299812741, nargs=4, arg_vector=0x00007fff5fbfdd30) + 1489 at eval.c:3045
>>>  frame #27: 0x0000000100201f6c Emacs`Ffuncall(nargs=5, args=0x00007fff5fbfdd28) + 1596 at eval.c:2861
>>>  frame #28: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4299811305, vector=4299811341, maxdepth=20, args_template=4345311290, nargs=0, args=0x0000000000000000) + 3504 at bytecode.c:916
>>>  frame #29: 0x0000000100203261 Emacs`funcall_lambda(fun=4299811205, nargs=2, arg_vector=0x00007fff5fbfe458) + 1489 at eval.c:3045
>>>  frame #30: 0x0000000100201f6c Emacs`Ffuncall(nargs=3, args=0x00007fff5fbfe450) + 1596 at eval.c:2861
>>>  frame #31: 0x00000001001faa43 Emacs`Fcall_interactively(function=4370705002, record_flag=4345311290, keys=4370471557) + 9155 at callint.c:836
>>>  frame #32: 0x0000000100201d9a Emacs`Ffuncall(nargs=4, args=0x00007fff5fbfe8d8) + 1130 at eval.c:2819
>>>  frame #33: 0x000000010025be60 Emacs`exec_byte_code(bytestr=4299358761, vector=4299358797, maxdepth=52, args_template=4100, nargs=1, args=0x00007fff5fbff030) + 3504 at bytecode.c:916
>>>  frame #34: 0x0000000100202e84 Emacs`funcall_lambda(fun=4299358717, nargs=1, arg_vector=0x00007fff5fbff028) + 500 at eval.c:2979
>>>  frame #35: 0x0000000100201f6c Emacs`Ffuncall(nargs=2, args=0x00007fff5fbff020) + 1596 at eval.c:2861
>>>  frame #36: 0x0000000100202839 Emacs`call1(fn=4370480538, arg1=4370705002) + 73 at eval.c:2611
>>>  frame #37: 0x00000001001421c7 Emacs`command_loop_1 + 2391 at keyboard.c:1559
>>>  frame #38: 0x00000001001ffb9c Emacs`internal_condition_case(bfun=0x0000000100141870, handlers=4370487930, hfun=0x000000010015bcf0) + 396 at eval.c:1348
>>>  frame #39: 0x000000010015bbe9 Emacs`command_loop_2(ignore=4345311290) + 41 at keyboard.c:1177
>>>  frame #40: 0x00000001001ff1d4 Emacs`internal_catch(tag=4370484122, func=0x000000010015bbc0, arg=4345311290) + 356 at eval.c:1112
>>>  frame #41: 0x0000000100140deb Emacs`command_loop + 187 at keyboard.c:1156
>>>  frame #42: 0x0000000100140cb4 Emacs`recursive_edit_1 + 132 at keyboard.c:777
>>>  frame #43: 0x0000000100140f97 Emacs`Frecursive_edit + 327 at keyboard.c:848
>>>  frame #44: 0x000000010013ef89 Emacs`main(argc=2, argv=0x00007fff5fbff680) + 5929 at emacs.c:1646
>>>  frame #45: 0x00007fff8ed825c9 libdyld.dylib`start + 1
>>> 
>>