Debug: 20gui_table_row_list_t.qsort(0, 18): enter
Debug: 20gui_table_row_list_t.qsort(0, 18): i = 0, pivot = data[p = 9], j = 18
Debug: gui_file_table_pak_column_t::compare_rows(): "3Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[i = 0] >= pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "3Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 18] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "ModernMental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 17] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "3Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 16] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 15] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 14] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 13] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 12] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 11] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 10] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 9] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 8] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 7] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 6] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 5] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 4] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 3] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 2] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "Pak128.Britain-Ex" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 1] > pivot
Debug: gui_file_table_pak_column_t::compare_rows(): "3Mental" > "Mental"
Debug: 20gui_table_row_list_t.qsort(0, 18): data[j = 0] > pivot
Segmentation fault
The segfault is because you aren't checking your bounds before array indexes. *Always* check your bounds before array indexes. Patch for bounds checking attached. :police: This returns us to the infinite loop.
Obviously, there's a second problem here -- "Mental" > "Mental"? I don't think so. And now that I know that's the problem, I think I know what the error is:
char s1[1024];
strcpy(s1, get_text(row1));
float f1 = strsim(s1, pak);
char s2[1024];
strcpy(s2, get_text(row2));
float f2 = strsim(s2, pak);
int result = sgn(f1 - f2);
You're using "sgn()" on floating-point numbers. You will practically always get +1 or -1. f1 - f2 may give a *signed zero* on a conformant floating point installation, and will likely give non-zero results due to roundoff error on any implementation. Comparison of floating point numbers (-, >, <) is dangerous if you expect to ever deal with two equal numbers. :police:
Rewrite strsim to use integers and this bug will probably go away.
EDITED: Verified. If I add a debug line to print out the comparison between the floats, I get this:
Debug: gui_file_table_pak_column_t::compare_rows() First P****: "0.142857" > "0.142857"

Floating point numbers cannot be used to generate a canonical comparison order. Even if you put a check for equality of strings up at the top of the routine, you'd still have to deal with the case of two different strings generating the same floating point number -- then the comparison of the "equal" floating point numbers could go different ways each time you do it.
FURTHER EDIT:
You can actually use floats if you want to.
The "floating point way" to test for equality is this:\
float diff = f1 -f2;
if ((diff > -.0001) && (diff < .0001) {
//....they're equal enough.....
return 0;
} else {
return sgn(diff);
}
Exact equality practically never occurs in floating point arithmetic, so you *always* have to do something like this.