public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] libctf: fix assertion failure with no system qsort_r
@ 2023-03-24 13:36 Nick Alcock
  2023-03-24 13:36 ` [PATCH 2/4] libctf: work around an uninitialized variable warning Nick Alcock
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Nick Alcock @ 2023-03-24 13:36 UTC (permalink / raw)
  To: binutils

If no suitable qsort_r is found in libc, we fall back to an
implementation in ctf-qsort.c.  But this implementation routinely calls
the comparison function with two identical arguments. The comparison
function that ensures that the order of output types is stable is not
ready for this, misinterprets it as a type appearing more that once (a
can-never-happen condition) and fails with an assertion failure.

Fixed, audited for further instances of the same failure (none found)
and added a no-qsort test to my regular testsuite run.

libctf/:
	PR libctf/30013
	* ctf-dedup.c (sort_output_mapping): Inputs are always equal to
	themselves.
---
 libctf/ctf-dedup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index c46f69e7449..6297c45c84d 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -2306,6 +2306,10 @@ sort_output_mapping (const ctf_next_hkv_t *one, const ctf_next_hkv_t *two,
   ctf_id_t one_type;
   ctf_id_t two_type;
 
+  /* Inputs are always equal to themselves.  */
+  if (one == two)
+    return 0;
+
   one_gid = ctf_dynhash_lookup (d->cd_output_first_gid, one_hval);
   two_gid = ctf_dynhash_lookup (d->cd_output_first_gid, two_hval);
 
-- 
2.39.1.268.g9de2f9a303


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

end of thread, other threads:[~2023-04-08 15:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 13:36 [PATCH 1/4] libctf: fix assertion failure with no system qsort_r Nick Alcock
2023-03-24 13:36 ` [PATCH 2/4] libctf: work around an uninitialized variable warning Nick Alcock
2023-03-24 13:36 ` [PATCH 3/4] libctf: fix a comment typo Nick Alcock
2023-03-24 13:36 ` [PATCH 4/4] libctf: get the offsets of fields of unnamed structs/unions right Nick Alcock
2023-03-25  6:07   ` Alan Modra
2023-03-27 10:27     ` Nick Alcock
2023-03-27 11:22       ` Alan Modra
2023-03-27 12:38         ` Nick Alcock
2023-04-06 11:46         ` Nick Alcock
2023-04-08 15:50           ` Nick Alcock

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).