On 04/02/2019 12:26, Nikolay Nikolov wrote:

On 2/3/19 11:22 PM, C Western wrote:
I suspect the new sorting routines need some work - lazarus compiled with the latest trunk hangs on start up, and it looks like an infinite loop in sorting. Stack trace below.

Even though the sort routine did slightly change, I believe this exposes a bug in lazarus. The CompareBinary routine in syneditmarkuphighall.pp returns -1 when the strings are equal, while it should return 0 in this case. This is like having two elements in the array, for which (a<b) and (b<a) are both true at the same time. The Compare function, passed to the sort algorithms must satisfy the mathematical properties of comparisons, otherwise the result is undefined (whether it should results in a hang (like in this case), or in a bad sort (like in the previous variation of the algorithm) is a separate discussion).

The attached patch fixes this.

I am happy to confirm lazarus starts with the patch applied.

Many thanks

Colin

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to