From: David Pirotte <david@altosw.be>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: make-c-struct and pointer->string
Date: Tue, 2 Apr 2019 15:03:42 -0300 [thread overview]
Message-ID: <20190402150342.7164ddae@capac> (raw)
In-Reply-To: <87v9zy6rd8.fsf@netris.org>
[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]
Hello Mark,
> >> 'make-c-struct' copies the C pointers from those foreign pointer objects, but
> >> not not keep a reference to the objects themselves.
> > To me, this sounds very counter intuitive, actually, it sounds like a bug,
> > make-c-struct should be holding a reference to the pointers it receives: i seems
> > to me that only when the c-struct itself becomes unreachable, that these
> > pointers could be freed?
> In my previous email I described some practical difficulties with
> implementing this suggestion, but I should rather emphasize a more
> important point:
> 'make-c-struct' is ultimately meant for passing data to C, and in
> general you should assume that Boehm GC will _not_ see references from C
> data structures to your GC-allocated objects.
> In fact, Boehm GC does _not_ scan objects allocated using C 'malloc',
> nor C++ 'new', nor 'make-c-struct'. So, for purposes of garbage
> collection, you should normally assume that passing pointers to C land
> is equivalent to passing them to a block hole.
> In general, when passing GC-allocated objects to C code, unless the C
> code in question was written with Boehm GC in mind, you must always
> think about how long the object must be kept alive, and arrange to keep
> a reference to it for at least that long, and preferably no longer than
> necessary or else you'll have space leaks.
> I'm open to suggestions of how to make this better, although I'm also
> fairly confident that interfacing between GC-managed and non-GC-managed
> code is a thorny problem with no silver bullets.
Answering the second of your 2 emails, but I did read the first as well ...
I agree with you, I think I somehow was only looking at one (of the many) way users
may use make-c-struct/parse-c-struct, and indeed I now see that my request would
even lead to mem problem, since most of the time, C may change these pointers or any
other struct field(s) content ...
Thanks again for your time and very good explanations.
Cheers,
David
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-04-02 18:03 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
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 [this message]
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=20190402150342.7164ddae@capac \
--to=david@altosw.be \
--cc=guile-devel@gnu.org \
--cc=mhw@netris.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).