public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31853] New: GDB's use of iconv does not work with macOS Sonoma
@ 2024-06-06 15:10 ciaranwoodward at xmos dot com
  2024-06-06 15:10 ` [Bug gdb/31853] " ciaranwoodward at xmos dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ciaranwoodward at xmos dot com @ 2024-06-06 15:10 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31853

            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=15569&action=edit
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 = "foobar"' then 'print s' would
print '$1 = "f"' rather than the expected '$1 = "foobar"'.

As far as I can tell, Apple silently swapped out the use of GNU libiconv for a
custom version in Sonoma, and the custom version is the only version present 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 issue
when they are run on Sonoma (since libiconv is dynamically linked).

I have attached a test program which exhibits the issue with the iconv function
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 Sonoma
is acting strangely'
Converted UTF-32LE string (in 100 byte chunks) is 38 chars: 'libiconv on Sonoma
is acting strangely'
Converted wchar_t string (in 4 byte chunks) is 38 chars: 'libiconv on Sonoma is
acting strangely'
Converted wchar_t string (in 100 byte chunks) is 38 chars: 'libiconv on Sonoma
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 Sonoma
is acting strangely'
Converted UTF-32LE string (in 100 byte chunks) is 38 chars: 'libiconv on Sonoma
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 Sonoma
is act'

```

The attached test program can be compiled with 'gcc -o test -liconv test.c'.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-12 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 15:10 [Bug gdb/31853] New: GDB's use of iconv does not work with macOS Sonoma ciaranwoodward at xmos dot com
2024-06-06 15:10 ` [Bug gdb/31853] " ciaranwoodward at xmos dot com
2024-06-06 15:25 ` ciaranwoodward at xmos dot com
2024-06-07 15:30 ` tromey at sourceware dot org
2024-06-07 16:18 ` ciaranwoodward at xmos dot com
2024-06-07 21:32 ` tromey at sourceware dot org
2024-06-10 16:16 ` ciaranwoodward at xmos dot com
2024-06-11 10:30 ` cvs-commit at gcc dot gnu.org
2024-06-11 15:08 ` tromey at sourceware dot org
2024-06-12 10:21 ` cvs-commit at gcc dot gnu.org
2024-06-12 12:39 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).