public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Cheng Jin" <jincheng@ca.ibm.com>
To: "Kaz Kylheku (libffi)" <382-725-6798@kylheku.com>
Cc: libffi-discuss@sourceware.org
Subject: RE: Incorrect data detected in the nested float struct with x86/libffi on Linux/64bit
Date: Wed, 9 Jun 2021 20:21:42 -0400	[thread overview]
Message-ID: <OFD8CE0AAE.2751F56B-ON002586F0.00016BAF-852586F0.0001FCA3@ibm.com> (raw)
In-Reply-To: <dc1d82f0f6d2ca17d31448e20a5fb9fb@mail.kylheku.com>

[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]




Hi Kaz,

Many thanks for your comments on the test code.

Actually it is not the test case used in our project but just to verify
whether it works good as expected.
The test code (already merged to the libffi tests at
https://github.com/libffi/libffi/pull/640 as requested by them) was
identified as a bug specific to x86_64 which will be investigated to see
what happens.


Thanks and Best Regards
Cheng Jin




From:	"Kaz Kylheku (libffi)" <382-725-6798@kylheku.com>
To:	Cheng Jin <jincheng@ca.ibm.com>
Cc:	libffi-discuss@sourceware.org
Date:	2021-06-09 07:48 PM
Subject:	[EXTERNAL] Re: Incorrect data detected in the nested float
            struct with  x86/libffi on Linux/64bit



On 2021-06-09 09:41, Cheng Jin via Libffi-discuss wrote:
> Hi,

Hi Cheng Jin,

A small matter on a tangent.

>
> 		   cls_struct_fields1[0] = &ffi_type_float;
> 		   cls_struct_fields1[1] = &cls_struct_type2;
> 		   cls_struct_fields1[2] = NULL;

Indeed, the array describing the element types of a structure must be
null terminated, so this is required.

> 		   cls_struct_type1.size = 0;
> 		   cls_struct_type1.alignment = 0;
> 		   cls_struct_type1.type = FFI_TYPE_STRUCT;
> 		   cls_struct_type1.elements = cls_struct_fields1;

Note that here, the size of the object is not indicated. That's why
the extra null pointer is required to infer the size.

>
> 		   dbl_arg_types[0] = &ffi_type_float;
> 		   dbl_arg_types[1] = &cls_struct_type1;
> 		   dbl_arg_types[2] = NULL;

But, for the argument array of a ffi_cif, no null termination is
required.

> 		  ffi_prep_cif(&cif_temp, FFI_DEFAULT_ABI, 2, retType,
dbl_arg_types);

No requirement for a null terminator is documented or appears in
examples. The 2 argument indicates the number of elements.

There is no harm in it; just pointing it out.

When I looked at your code, I went scrambling through documentation
to see if I was missing a required null terminator. :)

Cheers ...




[-- Attachment #2: graycol.gif --]
[-- Type: image/gif, Size: 105 bytes --]

  reply	other threads:[~2021-06-10  0:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 16:41 Cheng Jin
2021-06-09 16:50 ` Anthony Green
2021-06-09 17:53   ` Cheng Jin
2021-06-15 18:02   ` Jakub Jelinek
2021-06-15 19:02     ` Jakub Jelinek
2021-06-15 19:29       ` Anthony Green
2021-06-09 23:48 ` Kaz Kylheku (libffi)
2021-06-10  0:21   ` Cheng Jin [this message]
2021-06-10  2:05 ` Kaz Kylheku (libffi)
2021-06-10  2:39   ` Cheng Jin

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=OFD8CE0AAE.2751F56B-ON002586F0.00016BAF-852586F0.0001FCA3@ibm.com \
    --to=jincheng@ca.ibm.com \
    --cc=382-725-6798@kylheku.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).