From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: make-c-struct and pointer->string Date: Thu, 28 Mar 2019 15:42:25 +0000 Message-ID: References: <20190326101419.340081fc@capac> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="220204"; mail-complaints-to="usenet@blaine.gmane.org" Cc: guile-devel , David Pirotte To: Amirouche Boubekki Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Mar 28 17:11:34 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9Xcs-000v9e-A0 for guile-devel@m.gmane.org; Thu, 28 Mar 2019 17:11:34 +0100 Original-Received: from localhost ([127.0.0.1]:38801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9Xcr-0007p9-6I for guile-devel@m.gmane.org; Thu, 28 Mar 2019 12:11:33 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9XAt-00043N-Uy for guile-devel@gnu.org; Thu, 28 Mar 2019 11:42:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9XAs-0007xz-NM for guile-devel@gnu.org; Thu, 28 Mar 2019 11:42:39 -0400 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:35805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9XAs-0007wh-Cv for guile-devel@gnu.org; Thu, 28 Mar 2019 11:42:38 -0400 Original-Received: by mail-lj1-x235.google.com with SMTP id t4so4965683ljc.2 for ; Thu, 28 Mar 2019 08:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WYs1gGKlb0XfRIwuEy75xrv4k0h1IBLc8Yzczn7ssn4=; b=Qao0bjw2iI/+AnMi4WgVEN/WtV1uHchVjw4GbIa4a3kKhr2KU5bj31Q+SZgtwAX+pB lO4IxqFIxMpPjO+SqT2cqExyWnDu7jt2ZRaeG9thc/c7EHf9FW6ObObZ6hSP8+qAPktE jdM8TxYhcJ6gMhFfuCdIIUamwNEsTkTkcSPZHBoR+Nv7IgEQ9OhCS++2W+1L2tOkB6bG JzslPW7BVcneqQ/4oAh4JMap0r3OB53bgEYdBwp/7AISgSiod83FQLBMN83gvmpAK9b9 dyPIwMxSVHPwdtQgv6ooRZ4uSv17r9JU/8WvQQeCILjqXhGWFJMalLr/eEjCE68oePFd nr4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WYs1gGKlb0XfRIwuEy75xrv4k0h1IBLc8Yzczn7ssn4=; b=Ku5josnhikPDtlqeO0j8T8kLcaIb7EUXnVIBf7KxodySvajyY7/TMazRQfDy2XU4m9 gYhQt2a+GqXSYteQnawIhgnlYjtUjvdT7gu2o+GzMD34Pt4KyILAt8JqRlDVp8WezNCw DILcN1ilvyg+uOQ6fUdEKsPD9IeaY5UBjYSRsZ+bPIfNUQD0DjsbmU2Tl5SNN9diji1v 0g6V6ImJeaRABXeqFxXRr5Bp2iG3RTziAZw9TDcGWAu/sgJgonMWdVBGhsNSjs+zQ/7a Khj2dLAUzkFxNUzMIoZ51ayrE+LA2zDsBhGq3PGydo8Gn6+acr+HInkh7OsEaTxwIz36 gGQg== X-Gm-Message-State: APjAAAWTexOuKQY2pCmBl7M8UJEVgctsURYVO4iiTbZB8OYVb3Uv1I1/ DcN0M2VJRrRwicMvoILDwHhkrwa4XFnhSLyT1lxftnOSAgI= X-Google-Smtp-Source: APXvYqxTD7LzFiff/Xk11obZFFpeBWIAx0muIekNAmDTUWtpWP0ePy9yVc9UPZcqjjuzL/SrGBE8AQjdXz/zkYXKqNg= X-Received: by 2002:a2e:84cf:: with SMTP id q15mr22695046ljh.48.1553787756531; Thu, 28 Mar 2019 08:42:36 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::235 X-Mailman-Approved-At: Thu, 28 Mar 2019 12:11:24 -0400 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19866 Archived-At: On Thu, 28 Mar 2019 at 15:15, Amirouche Boubekki wrote: > > Eventually, I can reproduced the issue with guile-next from guix: > > scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->point= er "hello ") (string->pointer "there!"))) > $5 =3D # > scheme@(guile-user) [1]> (parse-c-struct $5 (list '* '*)) > $6 =3D (# #) > scheme@(guile-user) [1]> (map pointer->string $6) > $7 =3D ("hello " "there!") > scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->point= er "hello") (string->pointer "there!"))) > $8 =3D # > scheme@(guile-user) [1]> (parse-c-struct $8 (list '* '*)) > $9 =3D (# #) > scheme@(guile-user) [1]> (map pointer->string $9) > $10 =3D ("hello" "there!") > scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->point= er "hello") (string->pointer "there!"))) > $11 =3D # > scheme@(guile-user) [1]> (parse-c-struct $11 (list '* '*)) > $12 =3D (# #) > scheme@(guile-user) [1]> (map pointer->string $12) > $13 =3D ("?<\"?\x0e\x7f" "@?f\x01") > scheme@(guile-user) [1]> > scheme@(guile-user)> > > > Le mar. 26 mars 2019 =C3=A0 14:19, David Pirotte a =C3= =A9crit : >> >> Hello, >> >> guile 2.2.4.1-cdb19 >> >> ,use (system foreign) >> >> ;; this fails >> >> scheme@(guile-user)> (make-c-struct (list '* '*) (list (string->pointer = "hello ") (string->pointer "there!"))) >> $16 =3D # >> scheme@(guile-user)> (parse-c-struct $16 (list '* '*)) >> $17 =3D (# #) >> scheme@(guile-user)> (map pointer->string $17) >> $18 =3D ("?g?=D5=A3U" "`!?=D5=A3U") >> >> ;; but this works >> >> scheme@(guile-user)> (map pointer->string (parse-c-struct (make-c-struct= (list '* '*) (list (string->pointer "hello ") (string->pointer "there!")))= (list '* '*))) >> $19 =3D ("hello " "there!") I guess it may be GC. I've had problems with code like (procedure->pointer void (lambda (...) ...) args...) because procedure->pointer does not protect the (lambda ...) from being GC'= d. For example: http://git.savannah.nongnu.org/cgit/ossaulib.git/commit/?id=3D= 1d31a87b53e9375b5fdd5120b7d409e6dde6aa47 I wonder if there's a similar problem here with the string->pointer data. Best wishes, Neil