[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55212: GNU Linux "sort -g" can hang indefinitely when run on standar

From: Paul Eggert
Subject: bug#55212: GNU Linux "sort -g" can hang indefinitely when run on standard input if NaNs are involved
Date: Sun, 1 May 2022 23:03:38 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

Thanks for the bug report. This bug is entertaining, as it comes from GCC now being so smart that it optimizes away a memset that cleared padding bits. We added the memset in coreutils 8.14 (2011) to try to fix the sort -g infinite loop bug (introduced in 1999), but the memset isn't guaranteed to fix the bug because the memset can be optimized away.

If the padding bits happen to be clear already sort is OK, but if not the results can be inconsistent when you compare two NaNs to each other, and inconsistent results can make sort infloop.

The C standard allows this level of intelligence in the compiler, so it's a bug in GNU 'sort'.

I installed the attached patch; please give it a try. For now I'll boldly close the bug report; we can easily reopen it if this patch doesn't actually fix the problem.

Attachment: 0001-sort-fix-sort-g-infloop-again.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]