all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathieu Othacehe <othacehe@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 46796@debbugs.gnu.org
Subject: bug#46796: Cuirass & pointer finalization.
Date: Tue, 02 Mar 2021 18:02:40 +0100	[thread overview]
Message-ID: <87im69bia7.fsf@gnu.org> (raw)
In-Reply-To: <87blc1oeba.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 02 Mar 2021 14:50:01 +0100")


Hey,

> Hmm I think the bytevector and the pointer object can be finalized in
> the same GC cycle; when that happens, you have no guarantee as to the
> order in which they are finalized.

That would explain the crashes indeed.

> But… is it really similar to your ZMQ issue?  There you had message
> object wrappers (as per ‘define-wrapped-pointer-type’) and a pointer
> object to the underlying C object, right?

I think the only difference is that the reproducer doesn't introduce the
wrapped pointer object. Using ZMQ, the message creation looks like:

zmq-msg-init
    Bytevector creation with make-bytevector at address P
    Bytevector initialization with zmq_msg_init(P)
    Install zmq_msg_close as finalizer on P
    Message wrapping using (pointer->message P)
    Return the wrapped message

The user can then operate on the wrapped message by passing it to other
message API procedures such as zmq-message-size. Those procedures will
call ZMQ using the underlying pointer.

The bytevector/pointer object undetermined GC order is really
problematic then. I'm not sure why I'm not experiencing this crash using
Guardians since they are also using finalizers.

The ultimate work around would be to leave the message closing
responsibility to the user but that would be sad. Do you know if there's
another to prevent the bytevector from being collected before the
pointer object?

Thanks,

Mathieu




  reply	other threads:[~2021-03-02 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 14:14 bug#46796: Cuirass & pointer finalization Mathieu Othacehe
2021-02-26 20:12 ` zimoun
2021-02-27 12:59   ` Mathieu Othacehe
2021-02-27 12:50 ` Mathieu Othacehe
2021-03-01  9:37   ` Ludovic Courtès
2021-03-02  8:08     ` Mathieu Othacehe
2021-03-02 13:50       ` Ludovic Courtès
2021-03-02 17:02         ` Mathieu Othacehe [this message]
2021-03-08 13:45           ` Ludovic Courtès
2023-11-23 11:39 ` Ludovic Courtès

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

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

  git send-email \
    --in-reply-to=87im69bia7.fsf@gnu.org \
    --to=othacehe@gnu.org \
    --cc=46796@debbugs.gnu.org \
    --cc=ludo@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.