GNU bug report logs - #52451
27.1; jka-compr-write-region produces wrong type argument error

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Braun Gábor <braungb88@HIDDEN>; dated Sun, 12 Dec 2021 14:10:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 52451 <at> debbugs.gnu.org:


Received: (at 52451) by debbugs.gnu.org; 12 Dec 2021 18:53:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 12 13:53:55 2021
Received: from localhost ([127.0.0.1]:53120 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mwTys-0004GW-RL
	for submit <at> debbugs.gnu.org; Sun, 12 Dec 2021 13:53:55 -0500
Received: from mail-wm1-f47.google.com ([209.85.128.47]:41570)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <braungb88@HIDDEN>) id 1mwTyr-0004GK-8G
 for 52451 <at> debbugs.gnu.org; Sun, 12 Dec 2021 13:53:53 -0500
Received: by mail-wm1-f47.google.com with SMTP id
 az34-20020a05600c602200b0033bf8662572so10301916wmb.0
 for <52451 <at> debbugs.gnu.org>; Sun, 12 Dec 2021 10:53:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=fA3dl5SWVfNJfjGVDaFTjmmsEbVxIuNsZiYwgAeqrU0=;
 b=aXOKKevQM777PTTQtCpxG3Q+fIdGXsvY14f63j8t+mh5xzpNB4BgmbULBOWVJ0qeRj
 OM5O1b/TltONN0uof/x4tWUtA/F7T2Hy3GWyepF/Ax4Ve4vcdOR68lW8mqVE4/SndD7Y
 QSd6TvADrq5t8kt8ZWBtilIv4B61xDU+XuKmXtr/rT0UkkUyAlXhibIRkCG5xMsF9maQ
 UTsD4amG6vxiaMWTmSUuxBvF5aBFKp2Dy9p/vQWS0vtDFahAbGTfs923gNxhmL0nh+ul
 Ei/DKOCW9U+BrMNwfW6kG63ZIN8Hi7TvjjR8qOiTHWWizuxAj1oxM8+wLUkXBM78CSRi
 xhwA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=fA3dl5SWVfNJfjGVDaFTjmmsEbVxIuNsZiYwgAeqrU0=;
 b=t1VPPWgvzLPMI3rIdEurQeexomrgvrGPUSnn3qJwTRw7SQW/Ndt2O+c8QvroJKPImf
 J+XlJ5/uzlQAy4lEWkeAsXeuxiiC3E4TPzQ9cLeIe/YQsQ5V5CacTx6eux36EAyN/LO9
 f+YUltyVSTPi4JtTICTkGPVn80y8yIPiOIY9CIM0ZoPDM6OBtwcy1URvm6k2p5mM6OC7
 W7DnRVKUtctf6Bh1JcF43XmK51Clljy8eqfrTKZ83Bfb3SVlKp1soAKkeTUnkKWgelgy
 okjXj8NO+fne7LMUdM0Lc4hjckmq5nsfm/pvy5aD3tb5mdVcWwGR6n0T+O87UnK0kCN3
 VwRg==
X-Gm-Message-State: AOAM531KXm3T2nIfRipZNIix7l4S1CSEj1Vl3zTO8siO3VtHthF/lIR+
 w/RiIfKm0m35FI3SpogDHrw=
X-Google-Smtp-Source: ABdhPJwVFfC8Y2yG2WZAkKQeioTA5LP049ZizQfNI2vvfBm1XeEFO+JhlfpByx9arVjdPESQFpPQYg==
X-Received: by 2002:a7b:c1c9:: with SMTP id a9mr27279815wmj.152.1639335227082; 
 Sun, 12 Dec 2021 10:53:47 -0800 (PST)
Received: from gabor.localnet
 (dslb-092-078-124-054.092.078.pools.vodafone-ip.de. [92.78.124.54])
 by smtp.gmail.com with ESMTPSA id u13sm5400111wmq.14.2021.12.12.10.53.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 12 Dec 2021 10:53:46 -0800 (PST)
From: Braun =?ISO-8859-1?Q?G=E1bor?= <braungb88@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#52451: 27.1;
 jka-compr-write-region produces wrong type argument error
Date: Sun, 12 Dec 2021 19:53:38 +0100
Message-ID: <2994285.8uZclO0mQ2@gabor>
In-Reply-To: <83ilvtoq2u.fsf@HIDDEN>
References: <3230961.nYHENnkMsn@gabor> <83ilvtoq2u.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 52451
Cc: 52451 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

Hi Eli,

> When will write-region invoke jka-commpr-write-region if it is called
> with the first argument a string?

OK, here is a recipe.

$ echo FOO >test
$ gzip test
$ emacs -Q --batch -l jka-compr.el --eval '(let ((debug-on-error t)) (find-=
file=20
"test.gz") (write-region "foo" nil "foo.gz"))'                    =20
uncompressing jka-compr.el.gz...
uncompressing jka-compr.el.gz...done
uncompressing test.gz...
uncompressing test.gz...done
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  -(nil "foo")
  (=3D (- end start) (buffer-size))
  (or (null start) (=3D (- end start) (buffer-size)))
  (and jka-compr-really-do-compress (or (null start) (=3D (- end start) (bu=
ffer-
size))))
  (if (and jka-compr-really-do-compress (or (null start) (=3D (- end start)=
=20
(buffer-size)))) (setq magic nil))
  (let* ((filename (expand-file-name file)) (visit-file (if (stringp visit)=
=20
(expand-file-name visit) filename)) (info (jka-compr-get-compression-info v=
isit-
file)) (magic (and info (jka-compr-info-file-magic-bytes info)))) (if (and =
jka-
compr-really-do-compress (or (null start) (=3D (- end start) (buffer-size))=
))=20
(setq magic nil)) (if (and info (not (and magic (equal (if (stringp start)=
=20
(substring start 0 ...) (let* ... ...)) magic)))) (let ((can-append (jka-
compr-info-can-append info)) (compress-program (jka-compr-info-compress-
program info)) (compress-message (jka-compr-info-compress-message info))=20
(compress-args (jka-compr-info-compress-args info)) (base-name (file-name-
nondirectory visit-file)) temp-file temp-buffer (coding-system-used last-co=
ding-
system-used)) (or compress-program (error "No compression program defined")=
)=20
(setq temp-buffer (get-buffer-create " *jka-compr-wr-temp*")) (save-current-
buffer (set-buffer temp-buffer) (widen) (erase-buffer)) (if (and append (no=
t can-
append) (file-exists-p filename)) (let* ((local-copy (file-local-copy filen=
ame))=20
(local-file (or local-copy filename))) (setq temp-file local-file)) (setq t=
emp-file=20
(jka-compr-make-temp-name))) (and compress-message jka-compr-verbose (messa=
ge=20
"%s %s..." compress-message base-name)) (jka-compr-run-real-handler 'write-
region (list start end temp-file t 'dont)) (setq coding-system-used last-
coding-system-used) (let ((coding-system-for-read 'no-conversion)) (jka-com=
pr-
call-process compress-program (concat compress-message " " base-name) temp-=
file=20
temp-buffer nil compress-args)) (save-current-buffer (set-buffer temp-buffe=
r) (let=20
((coding-system-for-write 'no-conversion)) (jka-compr-run-real-handler 'wri=
te-
region (list (point-min) (point-max) filename (and append can-append) 'dont=
=20
lockname mustbenew)) (erase-buffer))) (delete-file temp-file) (and compress-
message jka-compr-verbose (message "%s %s...done" compress-message base-
name)) (cond ((eq visit t) (setq buffer-file-name filename) (setq jka-compr-
really-do-compress t) (set-visited-file-modtime)) ((stringp visit) (setq bu=
ffer-
file-name visit) (let ((buffer-file-name filename)) (set-visited-file-modti=
me))))=20
(and (or (eq visit t) (eq visit nil) (stringp visit)) (message "Wrote %s"=20
visit-file)) (setq last-coding-system-used coding-system-used) nil) (jka-co=
mpr-
run-real-handler 'write-region (list start end filename append visit lockna=
me=20
mustbenew))))
  jka-compr-write-region("foo" nil "/dev/shm/foo.gz" nil nil "/dev/shm/foo.=
gz"=20
nil)
  apply(jka-compr-write-region ("foo" nil "/dev/shm/foo.gz" nil nil "/dev/s=
hm/
foo.gz" nil))
  (if (and jka-op (not jka-compr-inhibit)) (apply jka-op args) (jka-compr-r=
un-
real-handler operation args))
  (let ((jka-op (get operation 'jka-compr))) (if (and jka-op (not jka-compr-
inhibit)) (apply jka-op args) (jka-compr-run-real-handler operation args)))
  (progn (let ((jka-op (get operation 'jka-compr))) (if (and jka-op (not jk=
a-
compr-inhibit)) (apply jka-op args) (jka-compr-run-real-handler operation=20
args))))
  (unwind-protect (progn (let ((jka-op (get operation 'jka-compr))) (if (an=
d=20
jka-op (not jka-compr-inhibit)) (apply jka-op args) (jka-compr-run-real-
handler operation args)))) (set-match-data save-match-data-internal=20
'evaporate))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn (le=
t=20
((jka-op (get operation 'jka-compr))) (if (and jka-op (not jka-compr-inhibi=
t))=20
(apply jka-op args) (jka-compr-run-real-handler operation args)))) (set-mat=
ch-
data save-match-data-internal 'evaporate)))
  jka-compr-handler(write-region "foo" nil "/dev/shm/foo.gz" nil nil "/dev/
shm/foo.gz" nil)
  write-region("foo" nil "foo.gz")
  (let ((debug-on-error t)) (find-file "test.gz") (write-region "foo" nil=20
"foo.gz"))
  eval((let ((debug-on-error t)) (find-file "test.gz") (write-region "foo" =
nil=20
"foo.gz")) t)
  command-line-1(("-l" "jka-compr.el" "--eval" "(let ((debug-on-error t))=20
(find-file \"test.gz\") (w..."))
  command-line()
  normal-top-level()

Best wishes,

	G=C3=A1bor







Information forwarded to bug-gnu-emacs@HIDDEN:
bug#52451; Package emacs. Full text available.

Message received at 52451 <at> debbugs.gnu.org:


Received: (at 52451) by debbugs.gnu.org; 12 Dec 2021 14:28:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 12 09:28:25 2021
Received: from localhost ([127.0.0.1]:51004 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mwPpx-0005iu-4n
	for submit <at> debbugs.gnu.org; Sun, 12 Dec 2021 09:28:25 -0500
Received: from eggs.gnu.org ([209.51.188.92]:45334)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1mwPpv-0005iZ-Kz
 for 52451 <at> debbugs.gnu.org; Sun, 12 Dec 2021 09:28:23 -0500
Received: from [2001:470:142:3::e] (port=60800 helo=fencepost.gnu.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mwPpq-0004Rr-Bk; Sun, 12 Dec 2021 09:28:18 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=3mQPDXOFIanuWa8P0offd6suJ4LqwiFndoDxAcRFS2w=; b=mozapxpKIqP9d5ab54bd
 X/Y8gz6zzTYp3JoH3qq8MWJ10RPuT3f5nRGLawVTLazNy1T3YO2avUaMQer7uoE2ykEF4k647XR08
 oPbXdyrLAsiBRrsv9SLd9sjKqh0s0d9lONdZEnHct06uD9TwULLNCeJiHwF/2APS9aVCRbx6ZjXy1
 p53GqJugFxEozoQh5hiqRJz+jlA0JsxcXYs/6LmMBHshzo1LyJaeDdFeWlICc4+kaxsM3ylCh6flZ
 2PZDJkIqj6SslDKtkxhn6cy/g8wSsecREeTetqsM22jVIyeKaDIXSlB351QQFoH1djToakhus3rsb
 DCduweAdXG9Vqg==;
Received: from [87.69.77.57] (port=3682 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1mwPpq-0002b2-4u; Sun, 12 Dec 2021 09:28:18 -0500
Date: Sun, 12 Dec 2021 16:28:09 +0200
Message-Id: <83ilvtoq2u.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Braun =?utf-8?Q?G=C3=A1bor?= <braungb88@HIDDEN>
In-Reply-To: <3230961.nYHENnkMsn@gabor> (message from Braun =?utf-8?Q?G?=
 =?utf-8?Q?=C3=A1bor?= on Sun, 12 Dec 2021 15:09:08 +0100)
Subject: Re: bug#52451: 27.1;
 jka-compr-write-region produces wrong type argument error
References: <3230961.nYHENnkMsn@gabor>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 52451
Cc: 52451 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Braun Gábor <braungb88@HIDDEN>
> Date: Sun, 12 Dec 2021 15:09:08 +0100
> 
> Start Emacs via the command
> 
>  emacs -Q --batch -l jka-compr.el --eval '(let ((jka-compr-really-do-compress 
> t) (debug-on-error t)) (jka-compr-write-region "foo" nil "/tmp/test.gz"))'        
> 
> 
> This should run without any error.
> Instead the following appears on the terminal:
> 
> 
> uncompressing jka-compr.el.gz...
> uncompressing jka-compr.el.gz...done
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   -(nil "foo")
>   (= (- end start) (buffer-size))
>   (or (null start) (= (- end start) (buffer-size)))

Why did you assume that jka-compr-write-region supports compressing a
string, not just a portion of a buffer?  I don't see it documented
anywhere.

> My guess is that the debugger refers to the following snippet
> in function `jka-commpr-write-region':
> 
>     ;; If we uncompressed this file when visiting it,
>     ;; then recompress it when writing it
>     ;; even if the contents look compressed already.
>     (if (and jka-compr-really-do-compress
>              (or (null start)
>                  (= (- end start) (buffer-size))))
> 	(setq magic nil))
> 
> This seems to falsely assume that START is nil or a buffer position,
> even though the docstring of `write-region' explicitly allows it to be a
> string.

When will write-region invoke jka-commpr-write-region if it is called
with the first argument a string?  That's the use case we should
discuss, not the direct invocation of jka-commpr-write-region in your
recipe, I think.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#52451; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Dec 2021 14:09:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 12 09:09:17 2021
Received: from localhost ([127.0.0.1]:50975 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mwPXR-0005HN-Dz
	for submit <at> debbugs.gnu.org; Sun, 12 Dec 2021 09:09:17 -0500
Received: from lists.gnu.org ([209.51.188.17]:46988)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <braungb88@HIDDEN>) id 1mwPXP-0005HG-PT
 for submit <at> debbugs.gnu.org; Sun, 12 Dec 2021 09:09:16 -0500
Received: from eggs.gnu.org ([209.51.188.92]:43522)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <braungb88@HIDDEN>)
 id 1mwPXP-0007el-Lj
 for bug-gnu-emacs@HIDDEN; Sun, 12 Dec 2021 09:09:15 -0500
Received: from [2a00:1450:4864:20::42e] (port=40455
 helo=mail-wr1-x42e.google.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <braungb88@HIDDEN>)
 id 1mwPXO-0007iR-17
 for bug-gnu-emacs@HIDDEN; Sun, 12 Dec 2021 09:09:15 -0500
Received: by mail-wr1-x42e.google.com with SMTP id t9so22892941wrx.7
 for <bug-gnu-emacs@HIDDEN>; Sun, 12 Dec 2021 06:09:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=akfXcf6xheuxg4cCcEaYzefU7S22uXHT/m9q3ZzBB60=;
 b=bEdmTk7uKY0lZ0H4wve83Ug3dRICt6JaWVGDjMNcqQxgoAMYI6Ki+dp6W2sC8B4XGB
 qE4wIngxbMzAHb1gud2wXBeXEOtO2at/c3rBEtNWOpvwrqodB1xVrbXNQaglLu4uD+1E
 lQlMdvYX7lgITxeODNpOGuoWLiL39zVXdmXJ6h7WuFHvc4qZJd0ECy75U3lWhxxeJQQL
 A8EPN9W7GCHzW4kD/RyeN5tXC1YmzqQAmgmSnJ7ofy0PBCQ2lt17+7uxNAD+EXJmcejv
 fMq/1kQeMm3F5urZwS8xhukLgDjmTa3X+SQ9OeRY+5Tum1WEre64pQZqNSO6IOWH5pvh
 BeQw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=akfXcf6xheuxg4cCcEaYzefU7S22uXHT/m9q3ZzBB60=;
 b=Mq1r4zLxEWC2sZVEts7y8aekkhSpmNR1bdzVllXOb8XFjEDvFMcsJ+UvR3z0OfsOwE
 wWCNeskxRyHs2O7AG/8kTmCMXeSNkN3a1qMxR66ApVDHwM9B0+VfuuoiQ9bd6Cia3vfJ
 FXV1aIOVOgFtzHjBQRAWVuMRk5vOA4lW/IeB77e52ukoVNHtgn5LpViz608o1Q8RgOmv
 lGUHp3rxiootCrhlKE24tHYN4CL5E4E/W/glOYTp0QqZ6H4PfkJw1Q8qNq4N2sGrmauP
 GrDPhHLed0xgsilqgOJ3nP6fASPAUNebDEqRRnLLAaBc98SLcOLL4Lzbx2Ml9e54ueab
 DIow==
X-Gm-Message-State: AOAM531l2Oe7tKqxImHD4WPOYPHTTwKnAzQ4VMbMPXpLuoxvFSuNKay5
 xQPV3SqQ8OrcCGnYM+4Tm/QLJ+Kdmwc=
X-Google-Smtp-Source: ABdhPJyPgYdHsSU6tqIfSKH/pD2jDqPMvnjO11moFa4jvx0hslPy8b1lSp/IpMSlHm+odyQp5/p6PA==
X-Received: by 2002:adf:e991:: with SMTP id h17mr25045790wrm.40.1639318152270; 
 Sun, 12 Dec 2021 06:09:12 -0800 (PST)
Received: from gabor.localnet
 (dslb-092-078-124-054.092.078.pools.vodafone-ip.de. [92.78.124.54])
 by smtp.gmail.com with ESMTPSA id 4sm11355454wrz.90.2021.12.12.06.09.10
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 12 Dec 2021 06:09:11 -0800 (PST)
From: Braun =?ISO-8859-1?Q?G=E1bor?= <braungb88@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.1; jka-compr-write-region produces wrong type argument error
Date: Sun, 12 Dec 2021 15:09:08 +0100
Message-ID: <3230961.nYHENnkMsn@gabor>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e
 (failed)
Received-SPF: pass client-ip=2a00:1450:4864:20::42e;
 envelope-from=braungb88@HIDDEN; helo=mail-wr1-x42e.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.2 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Hi,
 Start Emacs via the command emacs -Q --batch -l jka-compr.el
 --eval '(let ((jka-compr-really-do-compress t) (debug-on-error t))
 (jka-compr-write-region "foo" nil "/tmp/test.gz"))' 
 Content analysis details:   (1.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (braungb88[at]gmail.com)
 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends
 in digit (braungb88[at]gmail.com)
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,
 medium trust [209.51.188.17 listed in list.dnswl.org]
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [209.51.188.17 listed in wl.mailspike.net]
 1.3 SPOOFED_FREEMAIL       No description available.
 0.9 SPOOF_GMAIL_MID        From Gmail but it doesn't seem to be...
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

Hi,

Start Emacs via the command

 emacs -Q --batch -l jka-compr.el --eval '(let ((jka-compr-really-do-compre=
ss=20
t) (debug-on-error t)) (jka-compr-write-region "foo" nil "/tmp/test.gz"))' =
      =20


This should run without any error.
Instead the following appears on the terminal:


uncompressing jka-compr.el.gz...
uncompressing jka-compr.el.gz...done
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  -(nil "foo")
  (=3D (- end start) (buffer-size))
  (or (null start) (=3D (- end start) (buffer-size)))
  (and jka-compr-really-do-compress (or (null start) (=3D (- end start) (bu=
ffer-
size))))
  (if (and jka-compr-really-do-compress (or (null start) (=3D (- end start)=
=20
(buffer-size)))) (setq magic nil))
  (let* ((filename (expand-file-name file)) (visit-file (if (stringp visit)=
=20
(expand-file-name visit) filename)) (info (jka-compr-get-compression-info v=
isit-
file)) (magic (and info (jka-compr-info-file-magic-bytes info)))) (if (and =
jka-
compr-really-do-compress (or (null start) (=3D (- end start) (buffer-size))=
))=20
(setq magic nil)) (if (and info (not (and magic (equal (if (stringp start)=
=20
(substring start 0 ...) (let* ... ...)) magic)))) (let ((can-append (jka-
compr-info-can-append info)) (compress-program (jka-compr-info-compress-
program info)) (compress-message (jka-compr-info-compress-message info))=20
(compress-args (jka-compr-info-compress-args info)) (base-name (file-name-
nondirectory visit-file)) temp-file temp-buffer (coding-system-used last-co=
ding-
system-used)) (or compress-program (error "No compression program defined")=
)=20
(setq temp-buffer (get-buffer-create " *jka-compr-wr-temp*")) (save-current-
buffer (set-buffer temp-buffer) (widen) (erase-buffer)) (if (and append (no=
t can-
append) (file-exists-p filename)) (let* ((local-copy (file-local-copy filen=
ame))=20
(local-file (or local-copy filename))) (setq temp-file local-file)) (setq t=
emp-file=20
(jka-compr-make-temp-name))) (and compress-message jka-compr-verbose (messa=
ge=20
"%s %s..." compress-message base-name)) (jka-compr-run-real-handler 'write-
region (list start end temp-file t 'dont)) (setq coding-system-used last-
coding-system-used) (let ((coding-system-for-read 'no-conversion)) (jka-com=
pr-
call-process compress-program (concat compress-message " " base-name) temp-=
file=20
temp-buffer nil compress-args)) (save-current-buffer (set-buffer temp-buffe=
r) (let=20
((coding-system-for-write 'no-conversion)) (jka-compr-run-real-handler 'wri=
te-
region (list (point-min) (point-max) filename (and append can-append) 'dont=
=20
lockname mustbenew)) (erase-buffer))) (delete-file temp-file) (and compress-
message jka-compr-verbose (message "%s %s...done" compress-message base-
name)) (cond ((eq visit t) (setq buffer-file-name filename) (setq jka-compr-
really-do-compress t) (set-visited-file-modtime)) ((stringp visit) (setq bu=
ffer-
file-name visit) (let ((buffer-file-name filename)) (set-visited-file-modti=
me))))=20
(and (or (eq visit t) (eq visit nil) (stringp visit)) (message "Wrote %s"=20
visit-file)) (setq last-coding-system-used coding-system-used) nil) (jka-co=
mpr-
run-real-handler 'write-region (list start end filename append visit lockna=
me=20
mustbenew))))
  jka-compr-write-region("foo" nil "/tmp/test.gz")
  (let ((jka-compr-really-do-compress t) (debug-on-error t)) (jka-compr-wri=
te-
region "foo" nil "/tmp/test.gz"))
  eval((let ((jka-compr-really-do-compress t) (debug-on-error t)) (jka-comp=
r-
write-region "foo" nil "/tmp/test.gz")) t)
  command-line-1(("-l" "jka-compr.el" "--eval" "(let ((jka-compr-really-do-
compress t) (debug-on-e..."))
  command-line()
  normal-top-level()


My guess is that the debugger refers to the following snippet
in function `jka-commpr-write-region':

    ;; If we uncompressed this file when visiting it,
    ;; then recompress it when writing it
    ;; even if the contents look compressed already.
    (if (and jka-compr-really-do-compress
             (or (null start)
                 (=3D (- end start) (buffer-size))))
	(setq magic nil))

This seems to falsely assume that START is nil or a buffer position,
even though the docstring of `write-region' explicitly allows it to be a
string.

Best wishes,

     G=C3=A1bor Braun


In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cair=
o=20
version 1.16.0)
 of 2021-03-28, modified by Debian built on x86-conova-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Devuan GNU/Linux 4 (chimaera)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=3D/usr
 --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib
 --localstatedir=3D/var/lib --infodir=3D/usr/share/info
 --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes
 --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:=
/usr/
local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emac=
s/
site-lisp
 --with-sound=3Dalsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib
 --libexecdir=3D/usr/lib --localstatedir=3D/var/lib
 --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd
 --with-pop=3Dyes
 --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:=
/usr/
local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emac=
s/
site-lisp
 --with-sound=3Dalsa --without-gconf --with-mailutils --with-cairo
 --with-x=3Dyes --with-x-toolkit=3Dgtk3 --with-toolkit-scroll-bars
 'CFLAGS=3D-g -O2
 -ffile-prefix-map=3D/build/emacs-LlFm6W/emacs-27.1+1=3D. -fstack-protector=
=2Dstrong
 -Wformat -Werror=3Dformat-security -Wall' 'CPPFLAGS=3D-Wdate-time
 -D_FORTIFY_SOURCE=3D2' LDFLAGS=3D-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON PDUMPER LCMS2 GMP

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







Acknowledgement sent to Braun Gábor <braungb88@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#52451; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Dec 2021 19:00:02 UTC

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