Hi all, The attached patch fixes bugs in comparison functions qsort_cmp and compare_processes. I've tested the patch on x86_64-pc-linux-gnu (no regressions in testsuite except for flakiness in gdb.threads and bigcore.exp). These functions are passed to qsort(3) but do not obey standard symmetry requirements mandated by the standard (grep for "total ordering" in http://pubs.opengroup.org/onlinepubs/009695399/functions/qsort.html). This causes undefined behavior at runtime which can e.g. cause qsort to produce invalid results. Compare_processes fails to properly compare process group leaders which is probably a serious problem (e.g. resulting in invalid sort). Qsort_cmp fails to produce proper result when comparing same element. Sane qsort implementation probably don't call comparison callback on same element so this may not be a big problem in practice but I think it should still be fixed. NB1: please Cc: me explicitly, I'm not subscribed to the list. NB2: Bugs were found with SortChecker tool (https://github.com/yugr/sortcheck). Best regards, Yury Gribov