From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C01F7398BAA1; Thu, 6 Jun 2024 15:10:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C01F7398BAA1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1717686605; bh=awIgmkJZNGUxVHShC0gyyI/84/dA6FjNRRMqLIms22A=; h=From:To:Subject:Date:From; b=cKzztcA+1Tbh/KZkHWUSoaV/TXjLPREQWT/vuFZRrLo4BwPVV8p5+HzMRPRpSsB+E 7XTaKPIOy16FpmEbtOfBAncOrcFNnuIZ+2mbaG+RbLQzrcU0JVJ4q43868XnJXqcAw sywyADbbYSyMXbLWo66o09ffAEsJo9WEqmmqk404= From: "ciaranwoodward at xmos dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/31853] New: GDB's use of iconv does not work with macOS Sonoma Date: Thu, 06 Jun 2024 15:10:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ciaranwoodward at xmos dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31853 Bug ID: 31853 Summary: GDB's use of iconv does not work with macOS Sonoma Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: ciaranwoodward at xmos dot com Target Milestone: --- Created attachment 15569 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15569&action=3Ded= it Minimal reproduction test I noticed when using a cross-debugger on the latest macOS (Sonoma) that printing strings would only print the first character. For instance if there was a 'const char* s =3D "foobar"' then 'print s' wou= ld print '$1 =3D "f"' rather than the expected '$1 =3D "foobar"'. As far as I can tell, Apple silently swapped out the use of GNU libiconv fo= r a custom version in Sonoma, and the custom version is the only version presen= t on the new system. I'm not sure what the best fix is here, since even old built versions of GDB (for instance, built for Ventura) would experience this iss= ue when they are run on Sonoma (since libiconv is dynamically linked). I have attached a test program which exhibits the issue with the iconv func= tion in macOS. This replicates GDB's use of iconv with the wchar_iterator. I have also attached a patch which I applied locally to fix the issue, but maybe it seems a bit rough for general release? The expected test program output (and the output on older macOS or with GNU libiconv) is: ``` Input ASCII string: 'libiconv on Sonoma is acting strangely' Converted UTF-32LE string (in 4 byte chunks) is 38 chars: 'libiconv on Sono= ma is acting strangely' Converted UTF-32LE string (in 100 byte chunks) is 38 chars: 'libiconv on So= noma is acting strangely' Converted wchar_t string (in 4 byte chunks) is 38 chars: 'libiconv on Sonom= a is acting strangely' Converted wchar_t string (in 100 byte chunks) is 38 chars: 'libiconv on Son= oma is acting strangely' ``` The actual test program output on Sonoma is: ``` Input ASCII string: 'libiconv on Sonoma is acting strangely' Converted UTF-32LE string (in 4 byte chunks) is 38 chars: 'libiconv on Sono= ma is acting strangely' Converted UTF-32LE string (in 100 byte chunks) is 38 chars: 'libiconv on So= noma is acting strangely' Converted wchar_t string (in 4 byte chunks) is 1 chars: 'l' Converted wchar_t string (in 100 byte chunks) is 25 chars: 'libiconv on Son= oma is act' ``` The attached test program can be compiled with 'gcc -o test -liconv test.c'. --=20 You are receiving this mail because: You are on the CC list for the bug.=