GNU bug report logs - #60544
sort hangs on lengthy line with invalid UTF8 characters

Previous Next

Package: coreutils;

Reported by: "DE CARNE DE CARNAVALET, Xavier [COMP]" <xavier.decarnedecarnavalet <at> polyu.edu.hk>

Date: Wed, 4 Jan 2023 07:35:02 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 60544 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: "DE CARNE DE CARNAVALET, Xavier [COMP]"
 <xavier.decarnedecarnavalet <at> polyu.edu.hk>, 60544 <at> debbugs.gnu.org
Subject: Re: bug#60544: sort hangs on lengthy line with invalid UTF8 characters
Date: Sun, 8 Jan 2023 22:03:28 +0000
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




This bug report was last modified 2 years and 130 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.