I am encountring a panic inside the zig std lib sort code when I use a custom sort function. Normally the cause of a panic seems reasonably obvious, but in this case it is not. What would you suspect the cause of this bug to be?
(I am using a custom comparator cmp, and its only failing when I use one specific comparator but not the other. The comparator seems rather innocuous, so I dont think that is the problem. But I could be wrong )
thread 49651731 panic: integer overflow
/zig/zig-macos-aarch64-0.14.0/lib/std/sort/block.zig:520:73: 0x10046da4f in block__anon_31336 (praxis)
index = findFirstBackward(T, items, items[index - 1], Range.init(pull[pull_index].to, pull[pull_index].from - (count - 1)), length - count, context, lessThan);
^
/zig/zig-macos-aarch64-0.14.0/lib/std/mem.zig:601:19: 0x1004229f7 in sort__anon_24055 (praxis)
std.sort.block(T, items, context, lessThanFn);
^
/zig/praxis/src/search_index.zig:119:29: 0x100422667 in sort (praxis)
std.mem.sort(T, sr.*.partial_match.items, {}, cmp);
^
/zig/praxis/src/dictionary.zig:356:30: 0x1004234c3 in sort_search_results (praxis)
try self.by_form.sort();
^
/zig/praxis/src/dictionary.zig:220:37: 0x10042476f in load_text_data (praxis)
try self.sort_search_results();