From nobody Mon Jun 26 07:34:43 2023 X-Original-To: standards@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QqKNz2yznz4jHgm for ; Mon, 26 Jun 2023 07:34:43 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QqKNz0D5Cz3v11 for ; Mon, 26 Jun 2023 07:34:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687764883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cy1YU6gF0HM4uqbj/ZHS2bF0+wX2O+mImNfbT8ZG8/g=; b=lFWyt79IMfoYSF9XpOHH6VCfgDwMv/dWeKQzFIWun/jbClJdNhytCb5dM3gT8x+Mqhe2nL MkLRQmG68wbbXNEzh+nEdXsSrkbOu6/CcpLD9FDhyKV/JYtXQHHfEbILjbJFvJfUMQckAl dY84exWQMEmIvZ6czonWyhKwvYHBgtHL5nx78okWWHqGrBxh6HyTcPf8Owr99F9gKSCSYl ysn3hLfSJwyUkp55t5LdthM9vbiOJWWMQrJcKUN7EHYwBTQxuHlKkbKxooDYHlLIv2Ser9 FbdzkjX+pHoy7lyxQ11DDWB/IrngqecOWyN4EoiSx8QQ1CsqLGBxlCRjHU6svg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687764883; a=rsa-sha256; cv=none; b=voOtldDZa7pBdoeWKhUIIyZ2raTB1RsV8Qa0+3/7ZhVXkpj8a3D/twL7UcTDOBBhEpZx6g JEjdHGjjLL9FtLgt/RWUhmO/wK4fL7rPkZb/KGjBcB8n6OGpwMvWBPERaAfEvnZB4BKLGz EdHtIk2+2vhwGVDbHiiyQG6UmCUXCqXzU0bWR+r7bTpswvNo+VkV898K1/zNb0xPJD2rND kZ7IOsPo5NRFP2ip0mgj5o5awrhBmTUwdcQJOt/2SPw9yxWm1GrSZHBnjDd7fsM8z2R8FF HRMUnJzRKUjHEv0lsLuBApi14R5A32hkHpNykQDvKJy3PBfMJKKpWFWzx3D4yg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QqKNy6NqDz11wS for ; Mon, 26 Jun 2023 07:34:42 +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 35Q7YgVV008712 for ; Mon, 26 Jun 2023 07:34:42 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 35Q7YgnJ008711 for standards@FreeBSD.org; Mon, 26 Jun 2023 07:34:42 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: standards@FreeBSD.org Subject: [Bug 272218] mbsinit returns true for a state that is not in the initial state Date: Mon, 26 Jun 2023 07:34:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: bruno@clisp.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@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.mimetype 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 List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-standards@freebsd.org X-BeenThere: freebsd-standards@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272218 Bug ID: 272218 Summary: mbsinit returns true for a state that is not in the initial state Product: Base System Version: 13.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: bruno@clisp.org Attachment #243004 text/plain mime type: Created attachment 243004 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D243004&action= =3Dedit test case foo.c The following program makes 3 calls to the mbrtoc16 function and each time prints the results, including whether the mbstate_t in then in the initial state or not. Then it makes a second round, clearing the mbstate_t after the first call. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D foo.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #include #include #include #include int main () { if (setlocale (LC_ALL, "en_US.UTF-8") =3D=3D NULL) return 1; for (int round =3D 1; round <=3D 2; round++) { printf ("=3D=3D=3D Round %d =3D=3D=3D\n", round); mbstate_t state =3D { 0 }; char input[4] =3D { (char) 0xF0, (char) 0x9F, (char) 0x99, (char) 0x82 = }; /* U+1F642 */ char16_t wc =3D (char16_t) 0xDEADBEEF; int ret =3D mbrtoc16 (&wc, input, 4, &state); printf ("ret =3D %d, wc =3D 0x%04X, back_to_initial=3D%d\n", ret, (unsi= gned int) wc, mbsinit(&state) !=3D 0); if (round =3D=3D 2) memset (&state, '\0', sizeof(state)); if (ret =3D=3D 4) { wc =3D (char16_t) 0xDEADBEEF; ret =3D mbrtoc16 (&wc, input+4, 0, &state); printf ("ret =3D %d, wc =3D 0x%04X, back_to_initial=3D%d\n", ret, (un= signed int) wc, mbsinit(&state) !=3D 0); if (ret =3D=3D -2 || ret =3D=3D -3) { wc =3D (char16_t) 0xDEADBEEF; ret =3D mbrtoc16 (&wc, "", 0, &state); printf ("ret =3D %d, wc =3D 0x%04X, back_to_initial=3D%d\n", ret, (= unsigned int) wc, mbsinit(&state) !=3D 0); } } } return 0; } /* Expected output (seen on glibc, musl libc): =3D=3D=3D Round 1 =3D=3D=3D ret =3D 4, wc =3D 0xD83D, back_to_initial=3D0 ret =3D -3, wc =3D 0xDE42, back_to_initial=3D1 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 =3D=3D=3D Round 2 =3D=3D=3D ret =3D 4, wc =3D 0xD83D, back_to_initial=3D0 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 */ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D $ cc -Wall foo.c $ ./a.out =3D=3D=3D Round 1 =3D=3D=3D ret =3D 4, wc =3D 0xD83D, back_to_initial=3D1 ret =3D -3, wc =3D 0xDE42, back_to_initial=3D1 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 =3D=3D=3D Round 2 =3D=3D=3D ret =3D 4, wc =3D 0xD83D, back_to_initial=3D1 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 ret =3D -2, wc =3D 0xBEEF, back_to_initial=3D1 Since, after the first call, mbsinit() reports that the mbstate_t is in the initial state, it should make no difference if the program clears it (=3D f= orces it into the initial state) or not. But in FreeBSD 13.2, it makes a differen= ce: The output of round 2 is different from the output of round 1. This proves = that the mbstate_t was not in the initial state. That is, in the first line, mbsinit() should have returned zero instead of non-zero. Reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbsinit.html --=20 You are receiving this mail because: You are the assignee for the bug.=