Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with custom_sort #10968

Closed
Paluth opened this issue Sep 4, 2017 · 7 comments
Closed

Problem with custom_sort #10968

Paluth opened this issue Sep 4, 2017 · 7 comments
Milestone

Comments

@Paluth
Copy link

Paluth commented Sep 4, 2017

Hello,

I'm on Windows 10 with godot 2.1.4

OK, so on my computer there is a bug with custom_sort. And its a very strange bug. Because it doesn't always happen, or its sometimes different in the way it happens. So I wrote a table that you can sort columns. But sometimes I get an error when I try to sort a column.

The easiest way to reproduce the problem is to try to sort the third column first, before sorting any of the other columns. If you sort the third column after you sorted the first or the second sometimes it works out fine.

SortTest.zip

@memoryruins
Copy link

No issues with sorting over here. Potentially Windows related?

Arch Linux 64-bit
Godot 2.1.4

@memoryruins
Copy link

Tested again on:
Arch Linux 64-bit
Windows 10 64-bit
Windows 10 32-bit

It crashed on all three when trying to sort the third column first.

@vnen
Copy link
Member

vnen commented Sep 13, 2017

Can you describe the issue you're having? What do you expect to happen and what is actually happening? It's good to have a sample project but it shouldn't replace the description.

@Zireael07
Copy link
Contributor

The issue is, crash or error when you try to sort the third column first, as far as I can tell @vnen

@Paluth
Copy link
Author

Paluth commented Sep 19, 2017

@vnen I'm sorry the lack of description, but Zireael07 is right about the problem.
For some reason when you try to use the sort_custom function under certain conditions the program crashes. I don't know what those conditions are, but the sample project provided, reproduces the problem.
Sorting the third column first causes the issue.

@vnen
Copy link
Member

vnen commented Sep 19, 2017

Might be related to #3327.

@bojidar-bg
Copy link
Contributor

Can confirm it is related to #3327, since the comparison function returns true on equality, while it shouldn't.
Here is the crash backtrace:

(gdb) bt
#0  Map<StringName, _VariantCall::FuncData, Comparator<StringName>, DefaultAllocator>::has (this=0x556b5e9d7d48, p_key=...) at core/map.h:595
#1  0x00005555573570bf in Variant::has_method (this=0x7fffffff66c0, p_method=...) at core/variant_call.cpp:1178
#2  0x000055555583b0c4 in GDFunction::call (this=0x555559810a70, p_instance=0x555559821570, p_args=0x7fffffff7d20, p_argcount=2, r_err=..., p_state=0x0)
    at modules/gdscript/gd_function.cpp:488
#3  0x00005555558975aa in GDInstance::call (this=0x555559821570, p_method=..., p_args=0x7fffffff7d20, p_argcount=2, r_error=...) at modules/gdscript/gd_script.cpp:1112
#4  0x00005555573bcf22 in Object::call (this=0x5555598aa070, p_method=..., p_args=0x7fffffff7d20, p_argcount=2, r_error=...) at core/object.cpp:832
#5  0x0000555557264aa2 in _ArrayVariantSortCustom::operator() (this=0x7fffffff7ee8, p_l=..., p_r=...) at core/array.cpp:257
#6  0x0000555557264726 in SortArray<Variant, _ArrayVariantSortCustom>::partitioner (this=0x7fffffff7ee8, p_first=20, p_last=20, p_pivot=..., p_array=0x555559818dc8) at core/sort.h:167
#7  0x000055555726441a in SortArray<Variant, _ArrayVariantSortCustom>::introsort (this=0x7fffffff7ee8, p_first=0, p_last=20, p_array=0x555559818dc8, p_max_depth=7) at core/sort.h:192
#8  0x00005555572642f8 in SortArray<Variant, _ArrayVariantSortCustom>::sort_range (this=0x7fffffff7ee8, p_first=0, p_last=20, p_array=0x555559818dc8) at core/sort.h:288
#9  0x0000555557262e47 in SortArray<Variant, _ArrayVariantSortCustom>::sort (this=0x7fffffff7ee8, p_array=0x555559818dc8, p_len=20) at core/sort.h:295
#10 0x000055555726269f in Array::sort_custom (this=0x555559824200, p_obj=0x5555598aa070, p_function=...) at core/array.cpp:270
#11 0x00005555573a0f76 in _VariantCall::_call_Array_sort_custom (r_ret=..., p_self=..., p_args=0x7fffffff81b8) at core/variant_call.cpp:475
#12 0x0000555557394b26 in _VariantCall::FuncData::call (this=0x555558989288, r_ret=..., p_self=..., p_args=0x7fffffff81b8, p_argcount=2, r_error=...) at core/variant_call.cpp:118
#13 0x0000555557355af5 in Variant::call_ptr (this=0x5555598241f8, p_method=..., p_args=0x7fffffff81b8, p_argcount=2, r_ret=0x0, r_error=...) at core/variant_call.cpp:1005
#14 0x000055555583cd54 in GDFunction::call (this=0x555559829fb0, p_instance=0x5555597fe050, p_args=0x7fffffff9d78, p_argcount=1, r_err=..., p_state=0x0)
    at modules/gdscript/gd_function.cpp:638
... Cut off for clarity
#43 0x0000555555726df9 in main (argc=3, argv=0x7fffffffe468) at platform/x11/godot_x11.cpp:51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants