GNU bug report logs - #37480
27.0.50; uncaught exception

Previous Next

Package: emacs;

Reported by: Christian Johansson <christian <at> cvj.se>

Date: Sun, 22 Sep 2019 14:03:01 UTC

Severity: normal

Tags: moreinfo

Found in version 27.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37480 in the body.
You can then email your comments to 37480 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Sun, 22 Sep 2019 14:03:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christian Johansson <christian <at> cvj.se>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 22 Sep 2019 14:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christian Johansson <christian <at> cvj.se>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; uncaught exception
Date: Sun, 22 Sep 2019 16:00:38 +0200
I want to handle errors occurring in asynchronous threads like in this
example, is it possible?

(make-thread
(lambda()
(message "Start of asynchronous thread")
(signal 'error '("Fatal error"))
(message "End of asynchronous thread")))




In GNU Emacs 27.0.50 (build 5, x86_64-apple-darwin18.5.0, NS 
appkit-1671.40 Version 10.14.4 (Build 18E226))
of 2019-07-12 built on Christians-MacBook-Air.local
Repository revision: 8179cbff9ed37e7d8892643859adfad448ae1c7a
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1671
System Description: Mac OS X 10.14.4

Recent messages:
Mark activated
Auto-saving...done
Quit
Saving file 
/Users/christianjohansson/Documents/ownCloud/Mediastrategi/async.el...
Wrote /Users/christianjohansson/Documents/ownCloud/Mediastrategi/async.el
Quit
previous-line: Beginning of buffer
Mark set
M-g C-g is undefined
Quit
Quit
Configured features:
RSVG DBUS GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS THREADS PDUMPER GMP

Important settings:
value of $LANG: en_SE.UTF-8
locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
global-hl-todo-mode: t
hl-todo-mode: t
flycheck-color-mode-line-mode: t
show-paren-mode: t
save-place-mode: t
global-diff-hl-mode: t
diff-hl-mode: t
ssh-deploy-line-mode: t
global-auto-complete-mode: t
global-hl-line-mode: t
flyspell-mode: t
editorconfig-mode: t
which-key-mode: t
csv-field-index-mode: t
global-flycheck-mode: t
flycheck-mode: t
async-bytecomp-package-mode: t
yas-global-mode: t
yas-minor-mode: t
override-global-mode: t
ido-everywhere: t
display-time-mode: t
winner-mode: t
electric-pair-mode: t
recentf-mode: t
global-semantic-mru-bookmark-mode: t
global-semanticdb-minor-mode: t
global-semantic-idle-completions-mode: t
global-semantic-idle-scheduler-mode: t
global-semantic-idle-local-symbol-highlight-mode: t
global-semantic-idle-summary-mode: t
global-semantic-decoration-mode: t
global-semantic-highlight-func-mode: t
global-semantic-stickyfunc-mode: t
global-semantic-show-parser-state-mode: t
global-semantic-show-unmatched-syntax-mode: t
global-semantic-highlight-edits-mode: t
semantic-mode: t
delete-selection-mode: t
display-battery-mode: t
global-whitespace-mode: t
which-function-mode: t
shell-dirtrack-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
transient-mark-mode: t

Load-path shadows:
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-functions 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-functions
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-tags 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-tags
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-lexer 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-lexer
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-macros 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-macros
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-semantic 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-semantic
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-automation 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-automation
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-syntax-table 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-syntax-table
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-flymake 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode-flymake
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode 
hides /Users/christianjohansson/.emacs.d/phps-mode/phps-mode
/Users/christianjohansson/.emacs.d/phps-mode/phps-mode-test-functions 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-test-functions
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-functions 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-functions
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-tags 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-tags
/Users/christianjohansson/.emacs.d/phps-mode/phps-mode-test-integration 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-test-integration
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-lexer 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-lexer
/Users/christianjohansson/.emacs.d/phps-mode/phps-mode-test-parser hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-test-parser
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-macros 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-macros
/Users/christianjohansson/.emacs.d/phps-mode/phps-mode-test-lexer hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-test-lexer
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-semantic 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-semantic
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-autoloads 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-autoloads
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-automation 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-automation
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-syntax-table 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-syntax-table
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-flymake 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-flymake
/Users/christianjohansson/.emacs.d/phps-mode/phps-mode-test-syntax-table 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-test-syntax-table
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode-pkg 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode-pkg
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190918.701/phps-mode 
hides 
/Users/christianjohansson/.emacs.d/elpa/phps-mode-20190916.1730/phps-mode
/Users/christianjohansson/.emacs.d/ssh-deploy/ssh-deploy hides 
/Users/christianjohansson/.emacs.d/elpa/ssh-deploy-20181106.1347/ssh-deploy
/Users/christianjohansson/.emacs.d/ssh-deploy/ssh-deploy-diff-mode hides 
/Users/christianjohansson/.emacs.d/elpa/ssh-deploy-20181106.1347/ssh-deploy-diff-mode
/Users/christianjohansson/.emacs.d/elpa/less-css-mode-20161001.453/less-css-mode 
hides 
/Applications/Emacs.app/Contents/Resources/lisp/textmodes/less-css-mode
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/mantemp hides 
/Applications/Emacs.app/Contents/Resources/lisp/obsolete/mantemp

Features:
(shadow mail-extr emacsbug sendmail help-fns cl-print debug two-column
iso-transl phps-mode-tags phps-mode-syntax-table phps-mode-semantic
phps-mode-functions phps-mode-flymake semantic/doc phps-mode-lexer
phps-mode-macros semantic/wisent semantic/wisent/wisent names edebug
backtrace tar-mode arc-mode archive-mode view package-recipe-mode
package-build-badges package-build package-recipe vc-git vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs org-rmail org-mhe org-irc org-info org-gnus
nnir gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail
mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range gnus-win gnus
nnheader org-docview org-bibtex bibtex org-bbdb org-w3m
editorconfig-core editorconfig-core-handle editorconfig-fnmatch
display-line-numbers rainbow-mode hl-todo flycheck-rust
flycheck-color-mode-line face-remap cus-edit cus-start cus-load init
rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap smartparens-html
sgml-mode dom nxml-util nxml-enc xmltok misc ts-comint tss log4e helm
helm-source helm-multi-match helm-lib json-mode json-reformat
json-snatcher tide tide-lv typescript-mode zenburn-theme smarty-mode
paren saveplace mm-archive message rfc822 mml mml-sec epa derived epg
gnus-util rmail rmail-loaddefs text-property-search mailabbrev gmm-utils
mailheader gnutls network-stream url-cache restclient shackle trace smex
flycheck-pos-tip pos-tip diff-hl vc-dir ewoc vc vc-dispatcher diff-mode
exec-path-from-shell ssh-deploy-hydra ssh-deploy
emacs-wisent-grammar-converter nginx-mode ac-html ac-html-core
auto-complete-config auto-complete popup ztree ztree-diff
ztree-diff-model ztree-dir ztree-view ztree-util gulp-task-runner grunt
powerline powerline-separators powerline-themes phpcbf
php-auto-yasnippets php-mode php-project add-log cc-langs web-beautify
w3m doc-view jka-compr dired dired-loaddefs image-mode timezone w3m-hist
w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl w3m-favicon w3m-image w3m-proc
w3m-util hydra lv imenu-list hl-line auto-dictionary flyspell ispell
editorconfig ansible-doc org-jira org-jira-sdk jiralib request
mail-utils soap-client mm-decode mm-bodies mm-encode url-http url-auth
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw
nsm rmc puny rng-xsd rng-dt rng-util xsd-regexp xml org-clock
org-element avl-tree smartparens-org org org-macro org-footnote
org-pcomplete org-list org-faces org-entities time-date org-version
ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp
ob-comint ob-core ob-eval org-compat org-macs org-loaddefs cal-menu
calendar cal-loaddefs ecb ecb-symboldef ecb-analyse ecb-compatibility
ecb-winman-support ecb-autogen autoload radix-tree ecb-tod ecb-cycle
ecb-eshell ecb-help ecb-jde ecb-method-browser hideshow
ecb-semantic-wrapper ecb-semantic ecb-file-browser ecb-speedbar
ecb-layout ecb-create-layout ecb-compilation ecb-common-browser speedbar
sb-image dframe ecb-navigate eieio-compat ecb-mode-line ecb-face
tree-buffer ecb-upgrade ecb-cedet-wrapper semantic/db-find
semantic/db-ref ecb-util which-key csv-mode sort flycheck-package
package-lint finder finder-inf lisp-mnt flycheck flymake-rust
flymake-easy flymake-proc flymake warnings rust-playground time-stamp
cargo cargo-process smartparens-markdown markdown-mode color noutline
outline smartparens-rust rust-mode image+ image-file google-translate
google-translate-default-ui google-translate-core-ui
google-translate-core google-translate-tk url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf mailcap
lorem-ipsum darktooth-theme autothemer smartparens-config
smartparens-javascript smartparens-text smartparens paredit ripgrep
thingatpt grep compile minimap skewer-mode cache-table js2-mode etags
fileloop generator xref project js cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs simple-httpd pp
url-util doom-themes doom-themes-common base16-theme dracula-theme
with-editor async-bytecomp async server yasnippet yaxception ht dash
know-your-http-well http-status-codes http-relations http-methods
http-headers s use-package up-delight up-diminish up-ensure up-core
pcase cl bind-key easy-mmode ido time winner elec-pair desktop frameset
recentf tree-widget wid-edit semantic/mru-bookmark semantic/db-mode
semantic/idle semantic/analyze semantic/sort semantic/scope
semantic/analyze/fcn semantic/db eieio-base semantic/format ezimage
semantic/ctxt semantic/decorate/mode semantic/tag-ls semantic/find
semantic/decorate pulse semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local find-func cedet edmacro
kmacro delsel battery disp-table whitespace which-func imenu windmove
tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat
shell pcomplete comint ansi-color ring parse-time ls-lisp format-spec
wombat-theme rx cl-extra help-mode advice info package easymenu
epg-config url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win
ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow
isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 752194 242623)
(symbols 48 61091 23)
(strings 32 234066 45399)
(string-bytes 1 7200853)
(vectors 16 92145)
(vector-slots 8 1768635 188454)
(floats 8 768 1432)
(intervals 56 5603 3108)
(buffers 992 34))

-- 

Hälsningar / Best Regards
Christian





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Sun, 22 Sep 2019 14:51:01 GMT) Full text and rfc822 format available.

Message #8 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Christian Johansson <christian <at> cvj.se>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Sun, 22 Sep 2019 17:50:25 +0300
> From: Christian Johansson <christian <at> cvj.se>
> Date: Sun, 22 Sep 2019 16:00:38 +0200
> 
> I want to handle errors occurring in asynchronous threads like in this
> example, is it possible?

For some value of "possible".  From the ELisp manual:

     When code run by a thread signals an error that is unhandled, the
  thread exits.  Other threads can access the error form which caused the
  thread to exit using the following function.

   -- Function: thread-last-error
       This function returns the last error form recorded when a thread
       exited due to an error.  Each thread that exits abnormally
       overwrites the form stored by the previous thread’s error with a
       new value, so only the last one can be accessed.

> (make-thread
> (lambda()
> (message "Start of asynchronous thread")
> (signal 'error '("Fatal error"))
> (message "End of asynchronous thread")))

I'm not sure I understand what you tried to accomplish with this code.
It doesn't seem to handle errors in any way.  Could you explain what
you are trying to do?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Sun, 22 Sep 2019 15:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Christian Johansson <christian <at> cvj.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Sun, 22 Sep 2019 17:26:28 +0200
Hi!

Alright, I would like to do something like this:

(condition-case
    nil
    (make-thread
     (lambda()
       (message "Start of asynchronous thread")
       (signal 'error '("Fatal error"))
       (message "End of asynchronous thread")))
  (message "Catched error"))

I have a case were a error occurs inside a tramp thread and I would like 
to be able to handle it

Hälsningar / Best Regards
Christian

On 2019-09-22 16:50, Eli Zaretskii wrote:
>> From: Christian Johansson <christian <at> cvj.se>
>> Date: Sun, 22 Sep 2019 16:00:38 +0200
>>
>> I want to handle errors occurring in asynchronous threads like in this
>> example, is it possible?
> For some value of "possible".  From the ELisp manual:
>
>       When code run by a thread signals an error that is unhandled, the
>    thread exits.  Other threads can access the error form which caused the
>    thread to exit using the following function.
>
>     -- Function: thread-last-error
>         This function returns the last error form recorded when a thread
>         exited due to an error.  Each thread that exits abnormally
>         overwrites the form stored by the previous thread’s error with a
>         new value, so only the last one can be accessed.
>
>> (make-thread
>> (lambda()
>> (message "Start of asynchronous thread")
>> (signal 'error '("Fatal error"))
>> (message "End of asynchronous thread")))
> I'm not sure I understand what you tried to accomplish with this code.
> It doesn't seem to handle errors in any way.  Could you explain what
> you are trying to do?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Sun, 22 Sep 2019 15:40:01 GMT) Full text and rfc822 format available.

Message #14 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Christian Johansson <christian <at> cvj.se>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Sun, 22 Sep 2019 18:39:23 +0300
> Cc: 37480 <at> debbugs.gnu.org
> From: Christian Johansson <christian <at> cvj.se>
> Date: Sun, 22 Sep 2019 17:26:28 +0200
> 
> (condition-case
>      nil
>      (make-thread
>       (lambda()
>         (message "Start of asynchronous thread")
>         (signal 'error '("Fatal error"))
>         (message "End of asynchronous thread")))
>    (message "Catched error"))
> 
> I have a case were a error occurs inside a tramp thread and I would like 
> to be able to handle it

You don't need condition-case in this case, you just need to examine
the value of thread-last-error when the thread exits.

Alternatively, you could try making the thread you start signal the
main thread, then the main thread should be able to catch that error.

In general, errors are thread-local, so you cannot catch an error
signaled in another thread.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Sun, 22 Sep 2019 16:54:01 GMT) Full text and rfc822 format available.

Message #17 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Christian Johansson <christian <at> cvj.se>
Cc: 37480 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Sun, 22 Sep 2019 18:53:00 +0200
Christian Johansson <christian <at> cvj.se> writes:

> Hi!

Hi Christian,

> I have a case were a error occurs inside a tramp thread and I would
> like to be able to handle it

Could you give more details on the error inside a tramp thread? I'm
interested in.

Furthermore, Tramp in its own repository (not Emacs master) has more
support for threads. This includes better reports about errors inside
threads.

Hmm, maybe I shall sync this with the feature/tramp-thread-safe branch ...

> Hälsningar / Best Regards
> Christian

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Mon, 23 Sep 2019 05:19:02 GMT) Full text and rfc822 format available.

Message #20 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Christian Johansson <christian <at> cvj.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Mon, 23 Sep 2019 07:18:25 +0200
Hi

Alright, I didn't know about that function. Can you give an example of 
how to use it? It tried the following but it doesn't work, it seems the 
thread dies after the signal and I'm not sure were it exits.

(make-thread
 (lambda()
   (message "Start of asynchronous thread")
   (signal 'error '("Fatal error"))
   (message "End of asynchronous thread")
   (message "Last error %s" (thread-last-error))))

For my ssh-deploy plugin, sometimes a asynchronous process or thread 
gets an error, could be network issues for instance and I would like to 
be able to handle these cases. I'm trying to make sure there is only one 
asynchronous process or thread simultaneously related to a local file, 
this is to avoid race conditions that otherwise occur with my plugin, 
especially when on a bad connection.

I would be interested in exploring how to signal the main thread from 
the created thread, where can I read more about that?

Hälsningar / Best Regards
Christian

On 2019-09-22 17:39, Eli Zaretskii wrote:
>> Cc: 37480 <at> debbugs.gnu.org
>> From: Christian Johansson <christian <at> cvj.se>
>> Date: Sun, 22 Sep 2019 17:26:28 +0200
>>
>> (condition-case
>>       nil
>>       (make-thread
>>        (lambda()
>>          (message "Start of asynchronous thread")
>>          (signal 'error '("Fatal error"))
>>          (message "End of asynchronous thread")))
>>     (message "Catched error"))
>>
>> I have a case were a error occurs inside a tramp thread and I would like
>> to be able to handle it
> You don't need condition-case in this case, you just need to examine
> the value of thread-last-error when the thread exits.
>
> Alternatively, you could try making the thread you start signal the
> main thread, then the main thread should be able to catch that error.
>
> In general, errors are thread-local, so you cannot catch an error
> signaled in another thread.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Mon, 23 Sep 2019 07:16:01 GMT) Full text and rfc822 format available.

Message #23 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Christian Johansson <christian <at> cvj.se>
Cc: 37480 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Mon, 23 Sep 2019 09:14:51 +0200
Christian Johansson <christian <at> cvj.se> writes:

> Hi

Hi Christian,

> Alright, I didn't know about that function. Can you give an example of
> how to use it?

See .../test/src/thread-tests.el, function threads-errors.

> I would be interested in exploring how to signal the main thread from
> the created thread, where can I read more about that?

thread-signal does NOT raise an error if the target thread is the main
thread. You see just the message.

See .../test/src/thread-tests.el, function threads-signal-main-thread.

If you want a signal to be propagated to the main thread, you must
organise differently. For example checking thread-last-error, when the
main thread gets control.

> Hälsningar / Best Regards
> Christian

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Mon, 23 Sep 2019 16:39:01 GMT) Full text and rfc822 format available.

Message #26 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Christian Johansson <christian <at> cvj.se>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Mon, 23 Sep 2019 19:37:56 +0300
> Cc: 37480 <at> debbugs.gnu.org
> From: Christian Johansson <christian <at> cvj.se>
> Date: Mon, 23 Sep 2019 07:18:25 +0200
> 
> Alright, I didn't know about that function. Can you give an example of 
> how to use it? It tried the following but it doesn't work, it seems the 
> thread dies after the signal and I'm not sure were it exits.
> 
> (make-thread
>   (lambda()
>     (message "Start of asynchronous thread")
>     (signal 'error '("Fatal error"))
>     (message "End of asynchronous thread")
>     (message "Last error %s" (thread-last-error))))

This function is supposed to be used by a thread other than the one
that hit the error.

> For my ssh-deploy plugin, sometimes a asynchronous process or thread 
> gets an error, could be network issues for instance and I would like to 
> be able to handle these cases.

If you want to handle the error in the thread which gets the error,
just use condition-case or similar construct in that thread.  If you
want to handle the error in another thread, thread-last-error is for
you.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Tue, 24 Sep 2019 03:17:02 GMT) Full text and rfc822 format available.

Message #29 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Christian Johansson <christian <at> cvj.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 37480 <at> debbugs.gnu.org
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Tue, 24 Sep 2019 05:16:41 +0200
Ok thanks, now I understand

23 sep. 2019 kl. 18:37 skrev Eli Zaretskii <eliz <at> gnu.org>:

>> Cc: 37480 <at> debbugs.gnu.org
>> From: Christian Johansson <christian <at> cvj.se>
>> Date: Mon, 23 Sep 2019 07:18:25 +0200
>> 
>> Alright, I didn't know about that function. Can you give an example of 
>> how to use it? It tried the following but it doesn't work, it seems the 
>> thread dies after the signal and I'm not sure were it exits.
>> 
>> (make-thread
>>  (lambda()
>>    (message "Start of asynchronous thread")
>>    (signal 'error '("Fatal error"))
>>    (message "End of asynchronous thread")
>>    (message "Last error %s" (thread-last-error))))
> 
> This function is supposed to be used by a thread other than the one
> that hit the error.
> 
>> For my ssh-deploy plugin, sometimes a asynchronous process or thread 
>> gets an error, could be network issues for instance and I would like to 
>> be able to handle these cases.
> 
> If you want to handle the error in the thread which gets the error,
> just use condition-case or similar construct in that thread.  If you
> want to handle the error in another thread, thread-last-error is for
> you.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37480; Package emacs. (Thu, 07 Nov 2019 04:26:01 GMT) Full text and rfc822 format available.

Message #32 received at 37480 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Christian Johansson <christian <at> cvj.se>, 37480 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#37480: 27.0.50; uncaught exception
Date: Thu, 07 Nov 2019 05:25:38 +0100
tags 37480 + moreinfo
close 37480
thanks

Michael Albinus <michael.albinus <at> gmx.de> writes:

> Christian Johansson <christian <at> cvj.se> writes:
>
>> Hi!
>
> Hi Christian,
>
>> I have a case were a error occurs inside a tramp thread and I would
>> like to be able to handle it
>
> Could you give more details on the error inside a tramp thread? I'm
> interested in.
>
> Furthermore, Tramp in its own repository (not Emacs master) has more
> support for threads. This includes better reports about errors inside
> threads.
>
> Hmm, maybe I shall sync this with the feature/tramp-thread-safe branch ...

More information was requested, but none was given within 6 weeks, so
I'm closing this bug.  The rest of the discussion was clarifications
on how to use threads.

If there is still an issue here, please reopen the bug report.

Best regards,
Stefan Kangas




Added tag(s) moreinfo. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Thu, 07 Nov 2019 04:26:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 37480 <at> debbugs.gnu.org and Christian Johansson <christian <at> cvj.se> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Thu, 07 Nov 2019 04:26:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 Dec 2019 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 115 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.