Hacker News new | ask | show | jobs
by spullara 20 days ago
Fable 5.2 attempted a Lean proof and found a bug in the implementation, it has a fix though:

The published blqsort has a bug. In partition, the last loop in the C code only skips elements that are greater than or equal to the pivot. It assumes nothing unsorted is left, and that is false.

For example, take 2000 ones with x[1] = 2 and x[2] = 0. The C code returns 0 2 1 1 …, which is not sorted. It fails on about 3 of 4 random seeds.

In a C fuzz test of 20,000 random cases, 904 failed. The C++ and threaded versions have the same loop.

Because of this bug, no proof can show the published code is correct.

https://github.com/chkas/blqsort/issues/4

1 comments

Maintainer here. I've committed the fix. I have no idea why my other comment with this information was flagged.