From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#32938: guile 2.2.4 crashes (u8-list->bytevector (make-bytevector 32 0)) Date: Thu, 04 Oct 2018 19:49:21 -0400 Message-ID: <875zyhi872.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538696886 19119 195.159.176.226 (4 Oct 2018 23:48:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 4 Oct 2018 23:48:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32938@debbugs.gnu.org To: Josh Datko Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Oct 05 01:48:02 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g8DLd-0004r4-Uh for guile-bugs@m.gmane.org; Fri, 05 Oct 2018 01:48:02 +0200 Original-Received: from localhost ([::1]:60554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8DNk-0007Dx-2X for guile-bugs@m.gmane.org; Thu, 04 Oct 2018 19:50:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8DNe-0007Db-Ni for bug-guile@gnu.org; Thu, 04 Oct 2018 19:50:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8DNa-000503-Jp for bug-guile@gnu.org; Thu, 04 Oct 2018 19:50:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8DNa-0004zw-FQ for bug-guile@gnu.org; Thu, 04 Oct 2018 19:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g8DNa-0003Jc-DA for bug-guile@gnu.org; Thu, 04 Oct 2018 19:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 04 Oct 2018 23:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32938 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 32938-submit@debbugs.gnu.org id=B32938.153869698512713 (code B ref 32938); Thu, 04 Oct 2018 23:50:02 +0000 Original-Received: (at 32938) by debbugs.gnu.org; 4 Oct 2018 23:49:45 +0000 Original-Received: from localhost ([127.0.0.1]:37246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g8DNI-0003Iz-PK for submit@debbugs.gnu.org; Thu, 04 Oct 2018 19:49:44 -0400 Original-Received: from world.peace.net ([64.112.178.59]:60124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g8DNH-0003Ij-5Y for 32938@debbugs.gnu.org; Thu, 04 Oct 2018 19:49:43 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8DNA-0004a3-MO; Thu, 04 Oct 2018 19:49:36 -0400 In-Reply-To: (Josh Datko's message of "Thu, 4 Oct 2018 16:47:14 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9178 Archived-At: Josh Datko writes: > If you try to convert a bytevector, to a bytevector, using > u8-list->bytevector, guile crashes. > > $ guile -q > GNU Guile 2.2.4 > Copyright (C) 1995-2017 Free Software Foundation, Inc. > > Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. > This program is free software, and you are welcome to redistribute it > under certain conditions; type `,show c' for details. > > Enter `,help' for help. > scheme@(guile-user)> (use-modules (rnrs bytevectors)) > scheme@(guile-user)> (u8-list->bytevector (make-bytevector 32 0)) > [1] 126190 abort (core dumped) guile -q Indeed, the code in 'u8-list->bytevector' that's supposed to validate that its argument is a list, is broken. 'u8-list->bytevector' uses the SCM_VALIDATE_LIST_COPYLEN macro to validate the list and simultaneously compute its length. That macro implicitly assumes that its third operand will be a variable of type 'long', because the result of 'scm_ilength' is assigned to it, and 'scm_ilength' returns a 'long'. After storing the result to the variable, it checks to see if the result is negative, which would indicate that the operand wasn't a proper list. The bytevector operations that convert integer lists to bytevectors pass a variable of type 'size_t' to SCM_VALIDATE_LIST_COPYLEN. Since 'size_t' is unsigned, the -1 result from 'scm_ilength' was interpreted as ULONG_MAX instead. Thanks for the report. Mark