From owner-freebsd-bugs@freebsd.org Tue Nov 19 03:15:08 2019 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 37B65179E23 for ; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 47H9tN1WC9z3QCR for ; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 31CA1179E22; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 31870179E1E for ; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47H9tN1Kf4z3QCP for ; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 115CF41DD for ; Tue, 19 Nov 2019 03:15:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id xAJ3F8RP072397 for ; Tue, 19 Nov 2019 03:15:08 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id xAJ3F8M6072389 for bugs@FreeBSD.org; Tue, 19 Nov 2019 03:15:08 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 242067] r354823 riscv64 libC has a fault in printf() where IEEE754-2008 fp128 data is output wrong Date: Tue, 19 Nov 2019 03:15:06 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: dclarke@blastwave.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Nov 2019 03:15:08 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D242067 Bug ID: 242067 Summary: r354823 riscv64 libC has a fault in printf() where IEEE754-2008 fp128 data is output wrong Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: dclarke@blastwave.org Created attachment 209239 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D209239&action= =3Dedit Log of compile and output of assembly and check of fp128 data. I tested this on both r351523 ppc64 and riscv r350568 as well as the recent jenkins r354823 where valid and reasonable fp128 little endian data is mis-reported via printf thus :=20 /************************************************* * The Open Group Base Specifications Issue 6 * IEEE Std 1003.1, 2004 Edition *************************************************/ #define _XOPEN_SOURCE 600 #include #include #include #include #include #include #include #include #include int main ( int argc, char *argv[] ) { /* note hex representation of pi is=20 * 0x4000 0x921f 0xb544 0x42d1 0x8469 0x898c 0xc517 0x01b8 * IEEE754-2008 binary64 hex representation of pi is * 40 09 21 fb 54 44 2d 18 */ int j; long double pi =3D 3.14159265358979323846264338327950288419716939937510= L; struct utsname uname_data; setlocale( LC_MESSAGES, "C" ); if ( uname( &uname_data ) < 0 ) { fprintf ( stderr, "WARNING : Could not attain system uname data.\n" ); perror ( "uname" ); } else { printf ( "-------------------------------" ); printf ( "------------------------------\n" ); printf ( " system name =3D %s\n", uname_data.sysname ); printf ( " node name =3D %s\n", uname_data.nodename ); printf ( " release =3D %s\n", uname_data.release ); printf ( " version =3D %s\n", uname_data.version ); printf ( " machine =3D %s\n", uname_data.machine ); printf ( "-------------------------------" ); printf ( "------------------------------" ); } printf ("\n"); uint8_t x86_fp80[16] =3D { 0x35, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0x= c9, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00= }; printf("x86_fp80[16]\n"); printf(" 0x35, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9,\n"); printf(" 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n"); printf("out "); for ( j=3D0; j<16; j++ ) { printf("0x%02x ", ((uint8_t *)&x86_fp80)[j] ); } printf("\n"); printf(" x86_fp80 may be %38.34Le\n", *(long double*)&x86_fp80); printf(" x86_fp80 or be %18.14g\n", *(double*)&x86_fp80); printf("-------------------------------------------------\n"); uint8_t pi_fp64le[16] =3D { 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0= x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0= 0 }; printf("pi_fp64le[16]\n"); printf(" 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40,\n"); printf(" 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n"); printf("out "); for ( j=3D0; j<16; j++ ) { printf("0x%02x ", ((uint8_t *)&pi_fp64le)[j] ); } printf("\n"); printf(" pi_fp64le may be %38.34Le\n", *(long double*)&pi_fp64le); printf(" pi_fp64le or be %18.14g\n", *(double*)&pi_fp64le); printf("-------------------------------------------------\n"); uint8_t pi_fp64be[16] =3D { 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0= x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0= 0 }; printf("pi_fp64be[16]\n"); printf(" 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,\n"); printf(" 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n"); printf("out "); for ( j=3D0; j<16; j++ ) { printf("0x%02x ", ((uint8_t *)&pi_fp64be)[j] ); } printf("\n"); printf(" pi_fp64be may be %38.34Le\n", *(long double*)&pi_fp64be); printf(" pi_fp64be or be %18.14g\n", *(double*)&pi_fp64be); printf("-------------------------------------------------\n"); uint8_t pi_fp128le[16] =3D { 0xb8, 0x01, 0x17, 0xc5, 0x8c, 0x89, 0x69, = 0x84, 0xd1, 0x42, 0x44, 0xb5, 0x1f, 0x92, 0x00, 0x= 40 }; printf("pi_fp128le[16]\n"); printf(" 0xb8, 0x01, 0x17, 0xc5, 0x8c, 0x89, 0x69, 0x84,\n"); printf(" 0xd1, 0x42, 0x44, 0xb5, 0x1f, 0x92, 0x00, 0x40\n"); printf("out "); for ( j=3D0; j<16; j++ ) { printf("0x%02x ", ((uint8_t *)&pi_fp128le)[j] ); } printf("\n"); printf(" pi_fp128le may be %38.34Le\n", *(long double*)&pi_fp128le); printf(" pi_fp128le or be %18.14g\n", *(double*)&pi_fp128le);=20 printf("-------------------------------------------------\n"); uint8_t pi_fp128be[16] =3D { 0x40, 0x00, 0x92, 0x1f, 0xb5, 0x44, 0x42, = 0xd1, 0x84, 0x69, 0x89, 0x8c, 0xc5, 0x17, 0x01, 0x= b8 }; printf("pi_fp128be[16]\n"); printf(" 0x40, 0x00, 0x92, 0x1f, 0xb5, 0x44, 0x42, 0xd1,\n"); printf(" 0x84, 0x69, 0x89, 0x8c, 0xc5, 0x17, 0x01, 0xb8\n"); printf("out "); for ( j=3D0; j<16; j++ ) { printf("0x%02x ", ((uint8_t *)&pi_fp128be)[j] ); } printf("\n");=20=20=20=20=20=20=20 printf(" pi_fp128be may be %38.34Le\n", *(long double*)&pi_fp128be); printf(" pi_fp128be or be %18.14g\n", *(double*)&pi_fp128be); printf("-------------------------------------------------\n"); for ( j=3D0; j