unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neiljerram@gmail.com>
To: Amirouche Boubekki <amirouche.boubekki@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>, David Pirotte <david@altosw.be>
Subject: Re: make-c-struct and pointer->string
Date: Thu, 28 Mar 2019 15:42:25 +0000	[thread overview]
Message-ID: <CAKuG=vsySSSf8gpRq-iHpC9p3TcnOn1bknFQNm6Yf3JfJGnQkA@mail.gmail.com> (raw)
In-Reply-To: <CAL7_Mo_i8X6kddhsr0SxxEBo+cStOXnB4Sp30U5BHiw1TtveNA@mail.gmail.com>

On Thu, 28 Mar 2019 at 15:15, Amirouche Boubekki
<amirouche.boubekki@gmail.com> wrote:
>
> Eventually, I can reproduced the issue with guile-next from guix:
>
> scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello ") (string->pointer "there!")))
> $5 = #<pointer 0x1d1ca70>
> scheme@(guile-user) [1]> (parse-c-struct $5 (list '* '*))
> $6 = (#<pointer 0x166a950> #<pointer 0x166a9f0>)
> scheme@(guile-user) [1]> (map pointer->string $6)
> $7 = ("hello " "there!")
> scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello") (string->pointer "there!")))
> $8 = #<pointer 0x1ce2a40>
> scheme@(guile-user) [1]> (parse-c-struct $8 (list '* '*))
> $9 = (#<pointer 0x166a810> #<pointer 0x166a910>)
> scheme@(guile-user) [1]> (map pointer->string $9)
> $10 = ("hello" "there!")
> scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello") (string->pointer "there!")))
> $11 = #<pointer 0x1ce2a10>
> scheme@(guile-user) [1]> (parse-c-struct $11 (list '* '*))
> $12 = (#<pointer 0x166a850> #<pointer 0x166a690>)
> scheme@(guile-user) [1]> (map pointer->string $12)
> $13 = ("?<\"?\x0e\x7f" "@?f\x01")
> scheme@(guile-user) [1]>
> scheme@(guile-user)>
>
>
> Le mar. 26 mars 2019 à 14:19, David Pirotte <david@altosw.be> a écrit :
>>
>> 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 = #<pointer 0x55a3d54d54d0>
>> scheme@(guile-user)> (parse-c-struct $16 (list '* '*))
>> $17 = (#<pointer 0x55a3d5d12170> #<pointer 0x55a3d5d0a640>)
>> scheme@(guile-user)> (map pointer->string $17)
>> $18 = ("?g?գU" "`!?գU")
>>
>> ;; 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 = ("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=1d31a87b53e9375b5fdd5120b7d409e6dde6aa47

I wonder if there's a similar problem here with the string->pointer data.

Best wishes,
     Neil



  reply	other threads:[~2019-03-28 15:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 13:14 make-c-struct and pointer->string David Pirotte
2019-03-28 15:15 ` Amirouche Boubekki
2019-03-28 15:42   ` Neil Jerram [this message]
2019-03-29  8:48     ` David Pirotte
2019-03-29  9:46       ` David Pirotte
2019-03-29 19:08         ` Neil Jerram
2019-03-28 15:48   ` David Pirotte
2019-03-30 20:26 ` Mark H Weaver
2019-03-31 10:38   ` David Pirotte
2019-04-01  6:23     ` Mark H Weaver
2019-04-01  8:50     ` Mark H Weaver
2019-04-02 18:03       ` David Pirotte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKuG=vsySSSf8gpRq-iHpC9p3TcnOn1bknFQNm6Yf3JfJGnQkA@mail.gmail.com' \
    --to=neiljerram@gmail.com \
    --cc=amirouche.boubekki@gmail.com \
    --cc=david@altosw.be \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).