public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Stepan Golosunov <stepan@golosunov.pp.ru>
Cc: "Adhemerval Zanella Netto" <adhemerval.zanella@linaro.org>,
	"Andrew Pinski" <pinskia@gmail.com>,
	"Cristian Rodríguez" <cristian@rodriguez.im>,
	"Adhemerval Zanella via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: rustc SIGILL since qsort_r patches
Date: Tue, 07 Nov 2023 17:05:42 +0100	[thread overview]
Message-ID: <87pm0lblbd.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <ZUpQPFgkpXCFCfMm@sghpc.golosunov.pp.ru> (Stepan Golosunov's message of "Tue, 7 Nov 2023 18:57:00 +0400")

* Stepan Golosunov:

> On Tue, Nov 07, 2023 at 02:04:09PM +0100, Florian Weimer wrote:
>> * Adhemerval Zanella Netto:
>> 
>> > On 07/11/23 08:09, Florian Weimer wrote:
>> >> * Adhemerval Zanella Netto:
>> >> 
>> >>> Just a side note that the quicksort implementation was also used for
>> >>> size (number of elements times size per element) larger than the
>> >>> installed system RAM (_SC_PHYS_PAGES / size > _SC_PAGESIZE) or
>> >>> whether malloc fails.  So it is a latent issue, that did not trigger
>> >>> before by chance.  
>> >> 
>> >> Is it ever beneficial to call the comparison function with identical
>> >> pointers, though?
>> >
>> > Afaik this how introsort works, and I am not aware of any comparison
>> > sort with O(1) worst-case space complexity that does not require
>> > a comparison callback that work as <=>.
>> 
>> I think the LLVM code will only assert if it is called with equal
>> pointers, as the array elements are expected to be distinct (hence the
>> assert).
>> 
>> My question is more along these lines: If the pointers are equal, does
>> it make sense to perform the indirection function call?  I guess that
>> depends on the nature of the comparison function.
>> 
>> I'm not sure where equal-pointers call happens, but why wouldn't
>> something like this be an overall win?
>> 
>>   while (k <= n / 2)
>>     {
>>       size_t j = 2 * k;
>
> Shouldn't this be
>
>       size_t j = 2 * k + 1;
>
> instead? Looks like the existing formula is designed for base-1
> arrays.

Not sure, Adhemerval?

Obtaining the parent index would need adjusting then as well, right?

Thanks,
Florian


  reply	other threads:[~2023-11-07 16:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05  0:55 Cristian Rodríguez
2023-11-05  1:10 ` Andrew Pinski
2023-11-05  1:13   ` Andrew Pinski
2023-11-05 12:15     ` Cristian Rodríguez
2023-11-06 14:13   ` Adhemerval Zanella Netto
2023-11-07 11:09     ` Florian Weimer
2023-11-07 12:48       ` Adhemerval Zanella Netto
2023-11-07 13:04         ` Florian Weimer
2023-11-07 13:07           ` Adhemerval Zanella Netto
2023-11-07 13:13           ` Florian Weimer
2023-11-07 13:26             ` Adhemerval Zanella Netto
2023-11-07 14:02               ` Florian Weimer
2023-11-07 14:57           ` Stepan Golosunov
2023-11-07 16:05             ` Florian Weimer [this message]
2023-11-17 10:35               ` Florian Weimer
2023-11-17 11:44                 ` Adhemerval Zanella Netto
2023-11-17 13:33                   ` Florian Weimer
2023-11-17 13:57                     ` Florian Weimer
2023-11-17 16:17                       ` Florian Weimer
2023-11-17 18:37                         ` Adhemerval Zanella
2023-11-07 14:32 ` Florian Weimer
2023-11-08 14:19   ` Florian Weimer
2023-11-08 19:56     ` Cristian Rodríguez
2023-11-09 11:49       ` Cristian Rodríguez
2023-11-09 12:40         ` Adhemerval Zanella Netto

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=87pm0lblbd.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=cristian@rodriguez.im \
    --cc=libc-alpha@sourceware.org \
    --cc=pinskia@gmail.com \
    --cc=stepan@golosunov.pp.ru \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).