From: Jeff Law <jeffrey.law@oss.qualcomm.com>
To: Jan Dubiec <jdx@o2.pl>, gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: Re: [REPOST][PATCH v4] H8/300: sim: Fix simulator hang caused by qsort on Windows/MinGW
Date: Wed, 7 Oct 2026 20:04:13 -0600 [thread overview]
Message-ID: <a0633ef6-71e7-4b30-ba99-a20d12903643@oss.qualcomm.com> (raw)
In-Reply-To: <20261005060545.242055-1-jdx@o2.pl>
On 10/5/26 12:05 AM, Jan Dubiec wrote:
> On Windows, qsort() uses an unstable sorting algorithm, which results
> in a "shuffled" opcode table rather than a properly sorted one, causing
> the entire simulator to hang.
>
> The simulator happens to work on Linux, but this behavior is not
> guaranteed, because the glibc documentation clearly states that "If
> two elements compare equal, their order after sorting is unpredictable."
>
> This patch introduces two additional sort keys to the instruction
> comparator function, making the resulting opcode table as close as
> possible to the one that would be produced by a stable sorting algorithm.
>
> It also fixes an issue in the instruction decoder where, for example,
> mov.l @er7+,er1 is recognized as ldm.l @er7+,(er0-er1) if the opcode
> table is sorted "the wrong way", i.e. when ldm appears before mov
> in the table.
>
> No regressions were found.
This seems generally sensible to me. I'd probably kill that ldm/stm
special case, particularly if the new comparator avoids the problem.
I'd instead be more interested in tripping an assert if we ever have two
things compare equal
jeff
next prev parent reply other threads:[~2026-10-08 2:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 6:05 Jan Dubiec
2026-10-08 2:04 ` Jeff Law [this message]
2026-10-09 3:14 ` Jan Dubiec
2026-10-09 3:32 ` Jeff Law
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=a0633ef6-71e7-4b30-ba99-a20d12903643@oss.qualcomm.com \
--to=jeffrey.law@oss.qualcomm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jdx@o2.pl \
/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