From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 2538A385740F for ; Thu, 10 Jun 2021 00:21:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2538A385740F Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15A0ALGN192801; Wed, 9 Jun 2021 20:21:47 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3934ggw535-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Jun 2021 20:21:47 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15A0HFh8026920; Thu, 10 Jun 2021 00:21:46 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma03dal.us.ibm.com with ESMTP id 3900wa4tak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Jun 2021 00:21:46 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15A0Ljqa11076404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Jun 2021 00:21:45 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A521B112061; Thu, 10 Jun 2021 00:21:45 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AD7D112064; Thu, 10 Jun 2021 00:21:45 +0000 (GMT) Received: from mww0171.wdc07m.mail.ibm.com (unknown [9.208.70.164]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Jun 2021 00:21:45 +0000 (GMT) In-Reply-To: To: "Kaz Kylheku (libffi)" <382-725-6798@kylheku.com> Cc: libffi-discuss@sourceware.org Message-ID: From: "Cheng Jin" Date: Wed, 9 Jun 2021 20:21:42 -0400 Content-type: multipart/related; Boundary="0__=8FBB0C63DF92ED3F8f9e8a93df938690918c8FBB0C63DF92ED3F" References: X-KeepSent: D8CE0AAE:2751F56B-002586F0:00016BAF; name=$KeepSent; type=4 X-Mailer: IBM Notes Release 10.0.1 November 29, 2018 X-Disclaimed: 48083 X-MIMETrack: CD-MIME by Router on MWW0171/01/M/IBM at 06/10/2021 00:21:45, CD-MIME complete at 06/10/2021 00:21:45,Itemize by Router on MWW0171/01/M/IBM at 06/10/2021 00:21:45 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: esLxyqKAaE-VDOvn6Ev5iIJlCBOz0iRk X-Proofpoint-ORIG-GUID: esLxyqKAaE-VDOvn6Ev5iIJlCBOz0iRk X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 Subject: RE: Incorrect data detected in the nested float struct with x86/libffi on Linux/64bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-09_07:2021-06-04, 2021-06-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106090130 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TVD_FW_GRAPHIC_NAME_MID, 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 10 Jun 2021 00:21:56 -0000 --0__=8FBB0C63DF92ED3F8f9e8a93df938690918c8FBB0C63DF92ED3F Content-type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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 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] =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. > > 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 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 ... --0__=8FBB0C63DF92ED3F8f9e8a93df938690918c8FBB0C63DF92ED3F Content-type: image/gif; name="graycol.gif" Content-Disposition: inline; filename="graycol.gif" Content-ID: <1__=8FBB0C63DF92ED3F8f9e8a93df938690@ibm.com> Content-Transfer-Encoding: base64 R0lGODlhEAAQAKECAMzMzAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIXlI+py+0PopwxUbpu ZRfKZ2zgSJbmSRYAIf4fT3B0aW1pemVkIGJ5IFVsZWFkIFNtYXJ0U2F2ZXIhAAA7 --0__=8FBB0C63DF92ED3F8f9e8a93df938690918c8FBB0C63DF92ED3F--