public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* segfault in ffi_data_to_code_pointer
@ 2019-06-26 20:55 DJ Delorie
  2019-06-30 11:46 ` Anthony Green
  2019-07-04 12:35 ` Florian Weimer
  0 siblings, 2 replies; 9+ messages in thread
From: DJ Delorie @ 2019-06-26 20:55 UTC (permalink / raw)
  To: libffi-discuss; +Cc: Florian Weimer


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.

The following patch fixes the segfault, but I don't know if
segment_holding() returning NULL is an expected case, or a symptom of
problems elsewhere?

> diff -rup a/src/closures.c b/src/closures.c
> --- a/src/closures.c	2019-06-25 21:21:06.738743440 -0400
> +++ b/src/closures.c	2019-06-25 21:22:00.769716129 -0400
> @@ -621,7 +621,10 @@ void *
>  ffi_data_to_code_pointer (void *data)
>  {
>    msegmentptr seg = segment_holding (gm, data);
> -  return add_segment_exec_offset (data, seg);
> +  if (seg)
> +    return add_segment_exec_offset (data, seg);
> +  else
> +    return data;
>  }

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-04 12:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 20:55 segfault in ffi_data_to_code_pointer 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
2019-07-04  0:19             ` DJ Delorie
2019-07-04 12:35 ` Florian Weimer

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).