From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <382-725-6798@kylheku.com> Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by sourceware.org (Postfix) with ESMTPS id A74033857C68 for ; Wed, 9 Jun 2021 23:48:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A74033857C68 Received: from kylheku.com ([70.79.163.252]) by shaw.ca with ESMTPA id r7w5lMLjcycp5r7w7lC447; Wed, 09 Jun 2021 17:48:40 -0600 X-Authority-Analysis: v=2.4 cv=H864f8Ui c=1 sm=1 tr=0 ts=60c15358 a=95A0EdhkF1LMGt25d7h1IQ==:117 a=95A0EdhkF1LMGt25d7h1IQ==:17 a=IkcTkHD0fZMA:10 a=SMorJkV_YP8A:10 a=r6YtysWOX24A:10 a=E6cHRafV6xxIO_wMfbwA:9 a=QEXdDO2ut3YA:10 Received: from www-data by kylheku.com with local (Exim 4.72) (envelope-from <382-725-6798@kylheku.com>) id 1lr7w5-0002E6-CA; Wed, 09 Jun 2021 16:48:37 -0700 To: Cheng Jin Subject: Re: Incorrect data detected in the nested float struct with x86/libffi on Linux/64bit X-PHP-Originating-Script: 501:rcmail.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Wed, 09 Jun 2021 16:48:37 -0700 From: "Kaz Kylheku (libffi)" <382-725-6798@kylheku.com> Cc: libffi-discuss@sourceware.org In-Reply-To: References: Message-ID: X-Sender: 382-725-6798@kylheku.com User-Agent: Roundcube Webmail/0.9.2 X-CMAE-Envelope: MS4xfKUnORhb1ZMKFoEybbVIr8H4bURQBZZhU0FyYmSRBqJjAY74fCUFcGyORNKVOrPGt0eFPvEte/I5Du3STpJv8VbYNhNXz5EOprLGS9bP6VwpsyYuiM30 K27aHtEkBRSEAp+z75XFyebpbyOB5E+He/1PjibsVNVP24ZAm+nxfo2cJX8Ds6HSFi7M7Tj8f5mXGNXnT6f8d+0eTKm5V842B8OIPyLJpTSh6Qi6C0vGwlir X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FROM_STARTS_WITH_NUMS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2021 23:48:44 -0000 On 2021-06-09 09:41, Cheng Jin via Libffi-discuss wrote: > Hi, Hi Cheng Jin, A small matter on a tangent. >=20 > cls_struct_fields1[0] =3D &ffi_type_float; > cls_struct_fields1[1] =3D &cls_struct_type2; > cls_struct_fields1[2] =3D NULL; Indeed, the array describing the element types of a structure must be null terminated, so this is required. > cls_struct_type1.size =3D 0; > cls_struct_type1.alignment =3D 0; > cls_struct_type1.type =3D FFI_TYPE_STRUCT; > cls_struct_type1.elements =3D 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. >=20 > dbl_arg_types[0] =3D &ffi_type_float; > dbl_arg_types[1] =3D &cls_struct_type1; > dbl_arg_types[2] =3D NULL; But, for the argument array of a ffi_cif, no null termination is=20 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 ...