Subject: Re: bug#29548: 25.2; How to DEBUG get-device-terminal

From: Noam Postavsky <[email-masked]>
Date: Sun, 03 Dec 2017 11:09:23 -0500

Live System User <[email-masked]> writes:

> Hi,
>
>         I currently have an Emacs (GUI) proceaa giving the
>         error:
>
> get-device-terminal: Invalid argument #<terminal 5> in
> 'get-device-terminal'
> Error running timer battery-update-handler' (error Invalid argument
> #<terminal 5> in 'get-device-terminal'")
>
>         I belive this happened in my setup after I did the following
>         in conjuction with an Emacs daemon process:
>
>           (From a terminall shell prompt)
>           $ emacsclient -c file1.txt
>           (Emacs frame pops up)
>
>           From another terminal shell prompt::
>           $ emacsclient -t file1.txt
>           (terminal shows Emacs with file1.txt buffer)
>           'C-x 5 0' "(delete-frame)" in Emacs (TTY)
>           (terminal "clears" -- Emacs (TTY) mo longer on scree, as
>           expected, but mot returned to system shell prompt)
>           (Emacs (GUI) frame starts showing 'get-device-terminql'
>           error messages abd is umresponsive to any keyboard input)
>
>           This Emacs process is still avaiable to GDB, if useful.

Looks like that error comes from a condition-case-unless-debug handler
(in timer-event-handler).  Can you set `debug-on-error' from an
emacsclient and get a backtrace?  Otherwise I think 'break Fsignal' in
GDB should give some info as well (make sure that src/.gdbinit is
sourced so you get a lisp backtrace in addition to the C one).