From: Anthony Green <green@redhat.com>
To: DJ Delorie <dj@redhat.com>
Cc: Anthony Green <green@redhat.com>,
libffi-discuss@sourceware.org, fweimer@redhat.com
Subject: Re: segfault in ffi_data_to_code_pointer
Date: Wed, 03 Jul 2019 23:14:00 -0000 [thread overview]
Message-ID: <878ste90dy.fsf@laptop.atgreen.org> (raw)
In-Reply-To: <xnftnmsp9x.fsf@greed.delorie.com> (DJ Delorie's message of "Wed, 03 Jul 2019 18:54:02 -0400")
DJ Delorie <dj@redhat.com> writes:
> Anthony Green <green@redhat.com> writes:
>> No, they should be using ffi_closure_alloc().
>>
>> Can you point me at the ruby code that does this?
>
> ruby 2.6.3
> ext/fiddle/closure.c
Thanks. This looks right to me. Perhaps they wrote this before
ffi_closure_alloc() existed? I don't remember when every bit was
introduced... Looks like you need to follow up with the ruby people.
Thanks DJ,
AG
> In the failing case, USE_FFI_CLOSURE_ALLOC is not set
>
> static VALUE
> allocate(VALUE klass)
> {
> fiddle_closure * closure;
>
> VALUE i = TypedData_Make_Struct(klass, fiddle_closure,
> &closure_data_type, closure);
>
> fprintf (stderr, "DJ: allocate\n");
> #if USE_FFI_CLOSURE_ALLOC
> closure->pcl = ffi_closure_alloc(sizeof(ffi_closure), &closure->code);
> #else
> closure->pcl = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
> MAP_ANON | MAP_PRIVATE, -1, 0);
> #endif
>
> return i;
> }
>
> initialize()
> {
> . . .
> #if USE_FFI_CLOSURE_ALLOC
> result = ffi_prep_closure_loc(pcl, cif, callback,
> (void *)self, cl->code);
> #else
> result = ffi_prep_closure(pcl, cif, callback, (void *)self);
> cl->code = (void *)pcl;
> i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
> if (i) {
> rb_sys_fail("mprotect");
> }
> #endif
> . . .
> }
next prev parent reply other threads:[~2019-07-03 23:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 20:55 DJ Delorie
2019-06-30 11:46 ` Anthony Green
2019-07-02 23:47 ` DJ Delorie
2019-07-03 22:28 ` DJ Delorie
2019-07-03 22:47 ` Anthony Green
2019-07-03 22:54 ` DJ Delorie
2019-07-03 23:14 ` Anthony Green [this message]
2019-07-04 0:19 ` DJ Delorie
2019-07-04 12:35 ` Florian Weimer
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=878ste90dy.fsf@laptop.atgreen.org \
--to=green@redhat.com \
--cc=dj@redhat.com \
--cc=fweimer@redhat.com \
--cc=libffi-discuss@sourceware.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).