[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#60544: sort hangs on lengthy line with invalid UTF8 characters
From: |
Pádraig Brady |
Subject: |
bug#60544: sort hangs on lengthy line with invalid UTF8 characters |
Date: |
Sun, 8 Jan 2023 22:03:28 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0 |
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