Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async-start result mixes standard output with return value out of order on Emacs 27.1 for Windows #131

Closed
piyo opened this issue Sep 23, 2020 · 2 comments · Fixed by #170

Comments

@piyo
Copy link

piyo commented Sep 23, 2020

version

async package from melpa version "async-20200809.501"

description

On Emacs 27.1 for Windows, if the child process uses the message function, the arguments are inserted into the final result after the value to be passed back to the parent. The expected behavior is the arguments are not inserted after the value to be passed back to the parent.

repro 1

This code reproduces the problem:

(defvar scratch-1 nil)
(progn
  (setq async-debug t)
  (setq scratch-1 nil)
  (async-start
   `(lambda ()
      (message "yes")
      1)
   (lambda (result)
     (setq scratch-1 result))
   ))
;; result eventually stored in this global variable
scratch-1

On "GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) of 2020-08-22",
scratch-1 is '1yes and (type-of scratch-1) is 'symbol. (bad result)
Also the buffer *emacs* contains:

Lisp expression: 1yes\n

On "GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-12-31"
scratch-1 is 1 and (type of scratch-1) is 'integer. (good result)
Also the buffer *emacs* contains:

Lisp expression: yes\n
1

repro 2

Another example: This code reproduces the problem:

(defvar scratch-1 nil)
(progn
  (setq async-debug t)
  (setq scratch-1 nil)
  (async-start
   `(lambda ()
      (prin1 "omg")
      (message "hai")
      (message "yes")
      1)
   (lambda (result)
     (setq scratch-1 result))
   ))
;; result eventually stored in this global variable
scratch-1

On "GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) of 2020-08-22",
scratch-1 is 'yes and (type-of scratch-1) is 'symbol. (bad result)
Also the buffer *emacs* contains:

Lisp expression: "omg"1\n
hai\n
yes\n

On "GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-12-31"
scratch-1 is 1 and (type of scratch-1) is 'integer. (good result)
Also the buffer *emacs* contains:

Lisp expression: \n
hai\n
yes\n
"omg"1

repercussions

Currently this behavior breaks the paradox package when using async mode (paradox--menu-execute-1) and some of my non-published code.

workaround

One temporary workaround would be to silence the message function in the child, at the user provided start-func:

(async-start
   `(lambda ()
      (cl-letf (((symbol-function #'message) (symbol-function #'ignore)))
        (let ((child-var1 ...))
          (do-something)
          return-val-for-parent)))
   callback-in-parent)

This presumably breaks async-debug.

solution

Unknown.

@piyo
Copy link
Author

piyo commented Sep 23, 2020

I forgot to mention the following:
This cannot be reproduced on Emacs 27.1 on Debian.

@articuluxe
Copy link

On Darwin using Emacs 27.1, example 1 is even more broken, erroring out with: “error in process sentinel: End of file during parsing”. I think this is because the Emacs executable (from emacsforosx.com) uses ‘message to output all its loading activity at startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants