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

TimSort violations from brigadier #11852

Open
NewwindServer opened this issue Dec 28, 2024 · 0 comments · May be fixed by #11941
Open

TimSort violations from brigadier #11852

NewwindServer opened this issue Dec 28, 2024 · 0 comments · May be fixed by #11941
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added.

Comments

@NewwindServer
Copy link
Contributor

NewwindServer commented Dec 28, 2024

Stack trace

[16:31:41] [Async Tab Complete Thread - #0/ERROR]: Caught previously unhandled exception :
[16:31:41] [Async Tab Complete Thread - #0/ERROR]: Async Tab Complete Thread - #0
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.base/java.util.TimSort.mergeHi(TimSort.java:903) ~[?:?]
	at java.base/java.util.TimSort.mergeAt(TimSort.java:520) ~[?:?]
	at java.base/java.util.TimSort.mergeCollapse(TimSort.java:448) ~[?:?]
	at java.base/java.util.TimSort.sort(TimSort.java:245) ~[?:?]
	at java.base/java.util.Arrays.sort(Arrays.java:1308) ~[?:?]
	at java.base/java.util.ArrayList.sort(ArrayList.java:1804) ~[?:?]
	at com.mojang.brigadier.suggestion.Suggestions.create(Suggestions.java:99) ~[brigadier-1.3.10.jar:?]
	at com.mojang.brigadier.suggestion.SuggestionsBuilder.build(SuggestionsBuilder.java:51) ~[brigadier-1.3.10.jar:?]
	at com.mojang.brigadier.suggestion.SuggestionsBuilder.buildFuture(SuggestionsBuilder.java:55) ~[brigadier-1.3.10.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCustomCommandSuggestions0(ServerGamePacketListenerImpl.java:844) ~[paper-1.21.1.jar:1.21.1-DEV-d348cb8]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$1(ServerGamePacketListenerImpl.java:811) ~[paper-1.21.1.jar:1.21.1-DEV-d348cb8]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

The error is in brigadier, I opened an issue a few months back but they don't seem interested in fixing it, is it possible we can fix this from paper?

TLDR: string and integer types are mixed in the comparator which causes weird behaviour to be detected by Tim sort i.e. a < b, b < c but a < c which causes an error to be thrown.

Issue link and tech explanation here: Mojang/brigadier#154

Plugin and Datapack List

N/A

Actions to reproduce (if known)

This error can only happen if we are using paper AsyncTabCompleteEvent, doesn't happen with normal bukkit tab completers.

This code can replicate it, its very flaky though, you need to tab complete different commands a few times to trigger the error:

@EventHandler
    public void onTab(AsyncTabCompleteEvent event) {
        event.setCompletions(List.of(
                "124", "328  art", "64", "354", "98", "35", "101", "2", "110", "11", "74", "105", "150", "192", "30", "301",
                "103", "102", "40", "70", "24", "115", "122", "112", "15", "222", "99", "80", "326 <farm>", "20", "111", "205",
                "8", "71", "329 mine house", "6", "107", "51", "403  end tp", "104", "52", "235", "236", "203", "94",
                "327", "25", "4", "95", "304", "323", "33", "88", "93", "36", "45", "26", "82", "204", "53", "333 x stash",
                "32", "69", "234", "60", "335 treehouse", "47", "72", "210", "41", "325", "66", "5", "322", "332", "300",
                "206", "191", "75", "202", "302", "14", "882 weird lang", "324", "27", "19", "90", "3", "339 check!!!",
                "151", "169", "119", "190", "120", "201", "7", "13", "230", "81", "83", "239  mf", "23", "21", "320", "16",
                "97", "50", "65", "231", "114", "22", "303", "18", "5", "12", "91", "17", "121", "9", "125", "123", "73", "44124"
        ));
    }

Paper version

1.21.1 b48403b
99% sure issue still exists in 1.21.4 as brigadier version is the same in both and issue is inside brigadier.

Other

No response

@Malfrador Malfrador added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Jan 9, 2025
@emilyy-dev emilyy-dev linked a pull request Jan 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants