public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: Anthony Green <green@redhat.com>
Cc: libffi-discuss@sourceware.org, fweimer@redhat.com
Subject: Re: segfault in ffi_data_to_code_pointer
Date: Tue, 02 Jul 2019 23:47:00 -0000	[thread overview]
Message-ID: <xnmuhwrocq.fsf@greed.delorie.com> (raw)
In-Reply-To: <87o92fs3d2.fsf@laptop.atgreen.org> (message from Anthony Green on Sun, 30 Jun 2019 07:46:01 -0400)

> DJ Delorie <dj@redhat.com> writes:
>> In src/closures.c, ffi_data_to_code_pointer() calls segment_holding()
>> to get a pointer to the code segment for a data segment.  It doesn't
>> check for a NULL return, and I've got a test case where I run Ruby's
>> test suite (on a non-selinux aarch64 machine, if that matters) and
>> segment_holding() returns NULL and much hilarity ensues.

Anthony Green <green@redhat.com> writes:
> This suggests that the ffi_closure object used to invoke
> ffi_data_to_code_pointer wasn't allocated by ffi_closure_alloc().  Is
> that something you can check?

It seems to be so:

 [root ruby-2.6.3]# ./miniruby ./tool/runruby.rb -Itest/lib -r 'test/unit' "./test/fiddle/test_import.rb"
 < 0000ffffaa9b0000
 < 0000ffffaa900000
 Run options: 

The '<' lines indicate calls to ffi_data_to_code_pointer that had a NULL
segment, and the non-existing '>' lines indicated non-existing calls to
ffi_closure_allocate.

However, a simple NULL check may be the right fix anyway:

* it fixes the ruby build/test problem
* it does not re-introduce the illegal instruction bug

Which means that the non-code-seg'd closure isn't the one that triggers
the illegal instruction... but I don't know why still ;-)

  reply	other threads:[~2019-07-02 23:47 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 [this message]
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
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=xnmuhwrocq.fsf@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=green@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).