From: Aditya Kamath <Aditya.Kamath1@ibm.com>
To: Tom Tromey <tom@tromey.com>
Cc: Tom Tromey <tom@tromey.com>,
Aditya Vidyadhar Kamath <akamath996@gmail.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
"simon.marchi@polymtl.ca" <simon.marchi@polymtl.ca>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>
Subject: RE: [PATCH v2] Fix crash when target-wide-charset doesn't match wchar_t size
Date: Tue, 27 Oct 2026 11:18:43 +0000 [thread overview]
Message-ID: <DSWPR15MB3198170302C40C5522843EDFEDD6602@DSWPR15MB319817.namprd15.prod.outlook.com> (raw)
In-Reply-To: <871p9gqkmy.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]
Hi Tom and community members,
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__sourceware.org_pipermail_gdb-2Dpatches_2026-2DOctober_231148.html&d=DwIBAg&c=BSDicqBQBDjDI9RkVyTcHQ&r=f-oUQ8ByG1nZ71OI9p76qywCPh7mxzU69hBYnkP9Nis&m=ZqvNQdHjpMR8NN0gN2DAY-Qg76biG9X9nreFY45JXKG87ov0rUCcoCBwwm5e-m0d&s=mhF7tPz7DruvE3dGutyrsOFzFxdxwhNnTl7BB8s8a40&e=
>> Please see the stack in the mailing list link above I shared with
>> Simon. It has the backtrace plus core dump backtrace stack.
>Ok. It's kind of hard to read that message for me (there's no
>line-wrapping in the web browser); but I tend to think the bug is in
>wchar_iterator. I think it shouldn't be possible for it to read too
>much, or for m_bytes to wrap.
Thanks for the review. You were right that the bug is in wchar_iterator; the backtrace confirms it. On 64-bit AIX, wchar_t is 4 bytes wide, so the iterator is constructed with m_width = 4. When the target-wide charset is UTF-16, set_be_le_names resolves it to UTF-16BE, which uses 2-byte code units. In this case, iconv returns EILSEQ after consuming only 2 bytes, but the existing code still does:
m_input += m_width; /* advances by 4 */
m_bytes -= m_width; /* m_bytes was 4, wraps to a huge size_t */
The subsequent while (m_bytes > 0) loop then continues past the end of the buffer, eventually corrupting the stack and crashing inside libiconv's qsort. I will send a v3 that addresses this issue directly.
Regards,
Aditya.
[-- Attachment #2: Type: text/html, Size: 5981 bytes --]
prev parent reply other threads:[~2026-10-27 11:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 9:01 Aditya Vidyadhar Kamath
2026-10-23 18:36 ` Tom Tromey
2026-10-23 18:41 ` Aditya Kamath
2026-10-23 19:31 ` Tom Tromey
2026-10-27 11:18 ` Aditya Kamath [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DSWPR15MB3198170302C40C5522843EDFEDD6602@DSWPR15MB319817.namprd15.prod.outlook.com \
--to=aditya.kamath1@ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=akamath996@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=sangamesh.swamy@in.ibm.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox