From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Pal Gloss <pcfeb0009@gmx.com>
Newsgroups: gmane.emacs.bugs
Subject: bug#49922: 28.0.50;
 comp-run-async-workers can be broken by setting print-length or
 print-level
Date: Sat, 7 Aug 2021 09:48:32 +0200
Message-ID: <trinity-6a758042-fc68-4843-8a1f-222542297542-1628322512349@3c-app-mailcom-bs08>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="28316"; mail-complaints-to="usenet@ciao.gmane.io"
To: 49922@debbugs.gnu.org
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 07 09:49:12 2021
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1mCH4x-0007DV-Ru
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Aug 2021 09:49:11 +0200
Original-Received: from localhost ([::1]:40686 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1mCH4w-0002jL-K8
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Aug 2021 03:49:10 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47696)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1mCH4o-0002hN-SG
 for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 03:49:02 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43]:40352)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1mCH4o-0001Ah-Lt
 for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 03:49:02 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1mCH4o-0004LD-HZ
 for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 03:49:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Pal Gloss <pcfeb0009@gmx.com>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 07 Aug 2021 07:49:02 +0000
Resent-Message-ID: <handler.49922.B.162832252416657@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: report 49922
X-GNU-PR-Package: emacs
X-Debbugs-Original-To: bug-gnu-emacs@gnu.org
Original-Received: via spool by submit@debbugs.gnu.org id=B.162832252416657
 (code B ref -1); Sat, 07 Aug 2021 07:49:02 +0000
Original-Received: (at submit) by debbugs.gnu.org; 7 Aug 2021 07:48:44 +0000
Original-Received: from localhost ([127.0.0.1]:51898 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1mCH4V-0004Ka-Mc
 for submit@debbugs.gnu.org; Sat, 07 Aug 2021 03:48:44 -0400
Original-Received: from lists.gnu.org ([209.51.188.17]:56070)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pcfeb0009@gmx.com>) id 1mCH4Q-0004KP-5d
 for submit@debbugs.gnu.org; Sat, 07 Aug 2021 03:48:42 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47678)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pcfeb0009@gmx.com>) id 1mCH4P-0002Sm-TR
 for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 03:48:37 -0400
Original-Received: from mout.gmx.net ([212.227.15.18]:56969)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pcfeb0009@gmx.com>) id 1mCH4N-0000lC-Or
 for bug-gnu-emacs@gnu.org; Sat, 07 Aug 2021 03:48:37 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1628322512;
 bh=lMGkI8oSdEm0fZ5K55inG29uHxMvrcAjinxBTeUQM2w=;
 h=X-UI-Sender-Class:From:To:Subject:Date;
 b=NThLUAvfGxET8EAcbW6Vf9kal3wXPIb6MRi1qGG+j7LV0TByfFM/eaEsjcBgofVhE
 CenteR74nw6Krw0ncIPtJe7DR5WADXdhpn1joUdOeBnH7cfeWz7CDqs+PA3RjXbNKP
 vn+llAzdvcCdlC1qVKsB6kNCpxSxTnHJKjMHi3Es=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Original-Received: from [81.245.63.7] ([81.245.63.7]) by web-mail.gmx.net
 (3c-app-mailcom-bs08.server.lan [172.19.170.176]) (via HTTP); Sat, 7 Aug
 2021 09:48:32 +0200
Importance: normal
Sensitivity: Normal
X-Priority: 3
X-Provags-ID: V03:K1:5qOlduaATD7Ja5s61AxSZzBclwxrWtdU5KumcGWsCqeaC+0m/ml56tiZwru8UHe4Ym3zt
 SOHx+fMotEJDP5fJWdVhTx5NuQotdQgMVGfTlTcroIe05B9TX0rEfQwK4Us4ZXqC0VJZRmX0y6ur
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.227.15.18; envelope-from=pcfeb0009@gmx.com;
 helo=mout.gmx.net
X-Spam_score_int: -22
X-Spam_score: -2.3
X-Spam_bar: --
X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "bug-gnu-emacs"
 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Xref: news.gmane.io gmane.emacs.bugs:211360
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/211360>

`comp-run-async-workers' uses `prin1-to-string' to generate the contents
of a temporary file.  It does *NOT* rebind `print-length' and thus
inserts incomplete sexps in the temporary file.  This then leads to
errors during native compilation.

`print-level' is also not rebound to nil but it should, too.  I don't
really understand the failure mechanism, but I am pretty sure that the
usage of `prin1-to-string' in `comp-run-async-workers' intends to have a
faithful representation of its "expr" local variable in the "temp-file",
so that the right thing to do is to rebind those `print-level' and
`print-length' variables to isolate `comp-run-async-workers' from
whatever the settings the user may have at the time the compilation is
started.

Redefining `comp-run-async-workers' to bind `print-length' and
`print-level' to nil in the big `let*' expression inside the `cl-loop'
prevents the reproduction examples below from failing.



1. To reproduce the issue with `print-length' in emacs -Q:

(let* ((print-level nil)
       ;; 16 or lower gives "... error: (void-variable \.\.\.)"
       ;; 17 gives "... error: (wrong-number-of-arguments setf 17)"
       ;; 18 gives no error message nor warning (why?  No idea!)
       ;; 19 to 21 (bounds inclusive) give
       ;;          "Error: File is missing Cannot open load file"
       ;; 22 or higher: no error message nor warning
       (print-length 16)
       (temp-file (make-temp-file "reproduce-the-bug" nil ".el"))
       (_ (with-temp-file temp-file
            (insert "(defun reproduce-the-bug () nil)\n"))))
  (native-compile-async temp-file))

;; *Warnings* buffer pops up with
;;
;; Warning (comp): Debugger entered--Lisp error: (void-variable \.\.\.)
;;
;; or another error message depending on the value of `print-length'




2. To reproduce the issue with `print-level' in emacs -Q:

(let* ((print-level 2) ; 3 is already sufficient for the compilation to succeed
       (print-length nil)
       (temp-file (make-temp-file "reproduce-the-bug" nil ".el"))
       (_ (with-temp-file temp-file
            (insert "(defun reproduce-the-bug () nil\n"))))
  (native-compile-async temp-file))

;; *Warnings* buffer pops up with
;;
;; Warning (comp): <my home directory>/AppData/Local/Temp/reproduce-the-bugLyD27F.el: Error: error Cannot find suitable directory for output in `comp-native-load-path'.

In GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32)
 of 2021-08-06 built on <hostname>
Repository revision: 0afab352e02d7070a8ced2af53c1d01217400cdf
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 6.3.9600
System Description: Microsoft Windows 8.1 (v6.3.0.9600.20069)

Configured using:
 'configure --with-xml2 --with-zlib --without-pop
 --prefix=/home/username/emacs-native-comp/dest
 --without-compress-install --without-dbus --with-native-compilation
 --with-modules 'CFLAGS=-O2 -g3'
 PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB

Important settings:
  value of $LC_CTYPE: fr_FR.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-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
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail comp comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra
help-mode seq byte-opt gv cl-loaddefs cl-lib bytecomp byte-compile cconv
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils iso-transl
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars
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 tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer 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 cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 90320 10381)
 (symbols 48 8078 1)
 (strings 32 23631 1324)
 (string-bytes 1 795325)
 (vectors 16 16573)
 (vector-slots 8 322901 17594)
 (floats 8 30 72)
 (intervals 56 257 0)
 (buffers 992 12))