wanderlust / wanderlust

Wanderlust Development Repository
http://emacswiki.org/emacs/WanderLust
Other
397 stars 46 forks source link

Emacs is frozen on disconnect #225

Closed catap closed 4 months ago

catap commented 5 months ago

When I had running wl inside emacs I've disconnected from ethernet (and switched to wifi) which apparently changed machines IP and network.

After that Emacs going to consume 100% CPU and connect to it via lldb allow to get this trace:

(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00000001083f5159 Emacs`Fprocess_status + 25
    frame #1: 0x000000012f1a09a6 elmo-imap4-aa0b8008-68c2e96a.eln`F656c6d6f2d696d6170342d726561642d726573706f6e7365_elmo_imap4_read_response_0 + 182
    frame #2: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #3: 0x000000012f1a132b elmo-imap4-aa0b8008-68c2e96a.eln`F656c6d6f2d696d6170342d6163636570742d6f6b_elmo_imap4_accept_ok_0 + 75
    frame #4: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #5: 0x000000012f19f0f3 elmo-imap4-aa0b8008-68c2e96a.eln`F656c6d6f2d696d6170342d73656e642d636f6d6d616e642d77616974_elmo_imap4_send_command_wait_0 + 115
    frame #6: 0x00000001083e85c3 Emacs`exec_byte_code + 2828
    frame #7: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #8: 0x00000001083e85c3 Emacs`exec_byte_code + 2828
    frame #9: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #10: 0x000000011fd59f08 luna-c570f57f-aa8f5538.eln`F6c756e612d63616c6c2d6e6578742d6d6574686f64_luna_call_next_method_0 + 168
    frame #11: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #12: 0x000000011fd5a17a luna-c570f57f-aa8f5538.eln`F6c756e612d6170706c792d67656e65726963_luna_apply_generic_0 + 202
    frame #13: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #14: 0x000000012eac9746 elmo-7f6ea1ce-39c3310f.eln`F656c6d6f2d666f6c6465722d64696666_elmo_folder_diff_0 + 70
    frame #15: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #16: 0x000000012f02212b wl-folder-f0cb64a1-26c1d9a0.eln`F776c2d666f6c6465722d636865636b2d6f6e652d656e74697479_wl_folder_check_one_entity_0 + 3739
    frame #17: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #18: 0x000000012ecb74ab wl-util-44977a52-0c8b44ae.eln`F776c2d626966662d636865636b2d666f6c646572_wl_biff_check_folder_0 + 219
    frame #19: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #20: 0x000000012ecb70a0 wl-util-44977a52-0c8b44ae.eln`F776c2d626966662d636865636b2d666f6c64657273_wl_biff_check_folders_0 + 784
    frame #21: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #22: 0x000000012ecb681f wl-util-44977a52-0c8b44ae.eln`F776c2d626966662d6576656e742d68616e646c6572_wl_biff_event_handler_0 + 127
    frame #23: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #24: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #25: 0x000000010bc49578 timer-3ee7cfd9-faf18a90.eln`F74696d65722d6576656e742d68616e646c6572_timer_event_handler_0 + 1000
    frame #26: 0x00000001083a51d8 Emacs`Ffuncall + 353
    frame #27: 0x0000000108331f3d Emacs`timer_check + 942
    frame #28: 0x0000000108330147 Emacs`readable_events + 28
    frame #29: 0x0000000108331b45 Emacs`get_input_pending + 44
    frame #30: 0x000000010832feba Emacs`detect_input_pending_run_timers + 46
    frame #31: 0x00000001083fc227 Emacs`wait_reading_process_output + 4372
    frame #32: 0x000000010832da1a Emacs`read_char + 9059
    frame #33: 0x0000000108329901 Emacs`read_key_sequence + 1247
    frame #34: 0x0000000108327ec0 Emacs`command_loop_1 + 754
    frame #35: 0x00000001083a732e Emacs`internal_condition_case + 87
    frame #36: 0x0000000108327bbc Emacs`command_loop_2 + 41
    frame #37: 0x00000001083a6c5a Emacs`internal_catch + 81
    frame #38: 0x000000010847ce5f Emacs`command_loop.cold.1 + 72
    frame #39: 0x0000000108327613 Emacs`command_loop + 132
    frame #40: 0x0000000108327500 Emacs`recursive_edit_1 + 142
    frame #41: 0x00000001083276fe Emacs`Frecursive_edit + 208
    frame #42: 0x0000000108326a90 Emacs`main + 8278
    frame #43: 0x00000001160fe52e dyld`start + 462
  thread #2, name = 'gmain'
    frame #0: 0x00007ff80d07dd4a libsystem_kernel.dylib`__select + 10
    frame #1: 0x00000001099859f0 libglib-2.0.0.dylib`g_poll + 505
    frame #2: 0x0000000109977049 libglib-2.0.0.dylib`g_main_context_iterate_unlocked + 297
    frame #3: 0x00000001099770fc libglib-2.0.0.dylib`g_main_context_iteration + 55
    frame #4: 0x00000001099780e7 libglib-2.0.0.dylib`glib_worker_main + 30
    frame #5: 0x000000010999cce7 libglib-2.0.0.dylib`g_thread_proxy + 66
    frame #6: 0x00007ff80d0b24e1 libsystem_pthread.dylib`_pthread_start + 125
    frame #7: 0x00007ff80d0adf6b libsystem_pthread.dylib`thread_start + 15
  thread #3
    frame #0: 0x00007ff80d07a456 libsystem_kernel.dylib`__pselect + 10
    frame #1: 0x00007ff80d07a373 libsystem_kernel.dylib`pselect$DARWIN_EXTSN + 42
    frame #2: 0x000000010844334d Emacs`-[EmacsApp fd_handler:] + 201
    frame #3: 0x00007ff80dfce964 Foundation`__NSThread__start__ + 1009
    frame #4: 0x00007ff80d0b24e1 libsystem_pthread.dylib`_pthread_start + 125
    frame #5: 0x00007ff80d0adf6b libsystem_pthread.dylib`thread_start + 15
  thread #4, name = 'com.apple.NSEventThread'
    frame #0: 0x00007ff80d07596a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007ff80d075cd8 libsystem_kernel.dylib`mach_msg + 56
    frame #2: 0x00007ff80d17929d CoreFoundation`__CFRunLoopServiceMachPort + 319
    frame #3: 0x00007ff80d177928 CoreFoundation`__CFRunLoopRun + 1276
    frame #4: 0x00007ff80d176d6c CoreFoundation`CFRunLoopRunSpecific + 562
    frame #5: 0x00007ff80fd1f98e AppKit`_NSEventThread + 132
    frame #6: 0x00007ff80d0b24e1 libsystem_pthread.dylib`_pthread_start + 125
    frame #7: 0x00007ff80d0adf6b libsystem_pthread.dylib`thread_start + 15
  thread #5
    frame #0: 0x00007ff80d07704a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007ff80d0af034 libsystem_pthread.dylib`_pthread_wqthread + 426
    frame #2: 0x00007ff80d0adf57 libsystem_pthread.dylib`start_wqthread + 15
(lldb)

Seems that elmo-imap4-read-response doesn't handle well EOF at some cases :(

catap commented 5 months ago

It is reproducible almost each switch ethernet -> wifi

catap commented 5 months ago

To investigate that I've added that hack:

diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el
index 74a1d825..bb84fd88 100644
--- a/elmo/elmo-imap4.el
+++ b/elmo/elmo-imap4.el
@@ -467,8 +467,13 @@ COMMAND is a list of command tokens or a single command token."
 TAG is the tag of the command"
   (with-current-buffer (process-buffer
                         (elmo-network-session-process-internal session))
+    (setq elmo-imap4-read-response-loop-counter 0)
     (while (not (or (string= tag elmo-imap4-reached-tag)
                     (elmo-imap4-response-bye-p elmo-imap4-current-response)
+                    (when
+                        (> (setq elmo-imap4-read-response-loop-counter (1+ elmo-imap4-read-response-loop-counter)) 100)
+                      (message "elmo-imap4-read-response iterates more than 100 times, abort")
+                      t)
                     (when (elmo-imap4-response-garbage-p
                            elmo-imap4-current-response)
                       (message "Garbage response: %s"
catap commented 5 months ago

And I have:

elmo-imap4-read-response iterates more than 100 times, abort
wl-biff: error ((IMAP error: No `OK' response from server.))

this time it requires to press C-g, but at least I haven't lost emacs :)

catap commented 5 months ago

But I need to re-connect via double pressing M-t, otherwise emacs is seems blocked and C-g is required to wake it up.

catap commented 5 months ago

seems that this hack had broke wl-biff

catap commented 5 months ago

Seems that C-g is related to https://github.com/wanderlust/wanderlust/issues/148 and/or https://github.com/wanderlust/wanderlust/issues/213

catap commented 4 months ago

I can't reproduce this issue on c15e8ece4f34f10479e17cda19d10b98f6be3ec1 anymore.