bug-coreutils@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: "Pádraig Brady" <P@draigBrady.com>
To: "DE CARNE DE CARNAVALET,
	Xavier [COMP]" <xavier.decarnedecarnavalet@polyu.edu.hk>,
	60544@debbugs.gnu.org
Subject: bug#60544: sort hangs on lengthy line with invalid UTF8 characters
Date: Sun, 8 Jan 2023 22:03:28 +0000	[thread overview]
Message-ID: <f5db42ee-1b83-b71a-47cc-101a7bb87ea8@draigBrady.com> (raw)
In-Reply-To: <TYYP286MB3044FCE22F8A297AE174FA4BA3F59@TYYP286MB3044.JPNP286.PROD.OUTLOOK.COM>

tag 60544 notabug
close 60544
stop

On 04/01/2023 04:38, DE CARNE DE CARNAVALET, Xavier [COMP] wrote:
> sort seems to do extra computations on long line with invalid UTF8 characters and could hang for days on just two lines.
> 
> Here is the minimal example I could make to reproduce the bug:
> $ perl -e 'print "\xcd\xe5\xe0"; print "\n"' > file1
> $ perl -e 'print "\xcd\xe5\xe0"x1000; print "\n"' > file2

> Then:
> $ export LC_ALL=en_US.UTF8
> $ time sort --debug file1 file2
> sort: using 'en_US.UTF8' sorting rules
> [...]
> real    0m1.951s
> user    0m1.951s
> sys     0m0.000s
> 
> It took nearly two seconds to sort two lines from two files.
> If I replace the \xe0 with \x61 in the first (small) file, the time gets down to milliseconds:

If I profile sort like:

   $ src/sort file1 file2 >/dev/null & perf top -p $!

It shows that all the time is spent in libc's __strcoll_l
I see one strcoll performance bug which might be related:
https://sourceware.org/bugzilla/show_bug.cgi?id=18441

I'd follow up with glibc, also specifying your glibc version.

Marking this as not a coreutils bug for now.

cheers,
Pádraig




      reply	other threads:[~2023-01-08 22:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  4:38 bug#60544: sort hangs on lengthy line with invalid UTF8 characters DE CARNE DE CARNAVALET, Xavier [COMP]
2023-01-08 22:03 ` Pádraig Brady [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

  List information: https://lists.gnu.org/mailman/listinfo/bug-coreutils

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5db42ee-1b83-b71a-47cc-101a7bb87ea8@draigBrady.com \
    --to=p@draigbrady.com \
    --cc=60544@debbugs.gnu.org \
    --cc=xavier.decarnedecarnavalet@polyu.edu.hk \
    /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).