[boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

This subforum contains all the issues which we already resolved.
teiriko
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Oct 27, 2024 8:16 am
Contact:

[boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by teiriko »

Description
When the selector combinator is set to "Sort ascending" and there are at least 8 signals in the network, the returned value of some indexes is wrong (see example below)
Example
Notes:
- on the left side all the selector combinators are set to "Sort descending" - everything is in order
- the right side fully copies the left side with the difference that "Sort ascending" is chosen - 5 and 6 should be switched
- below the setup, the marked combinator is opened, hopefully providing proof that I was not going crazy for the last 2 hours - the returned value should be 5
10-29-2024, 17-06-50.png
10-29-2024, 17-06-50.png (603 KiB) Viewed 1427 times
Blueprint

Code: Select all

0eNrlmNFuozAQRf/Fz26FsY0x0u6PRFVEEqe1BIYF0t0oyr/v2ASCKu9SLPGEKrUXx5y5Hs9MpN7QobioutGmQ9kN6WNlWpTtbqjV7yYv7JrJS4Uy1KpCHbuqeTlW5UGbHCS6Y6TNSf1BGbm/YaRMpzuteoB7uO7NpTyoBjbgAWRDdLnppiCM6qqFdytjI1oej145RleUyeSVQxx4q2uqYn9QH/mnhldgXwuGtDM81RB7MIXRWRedar6udtfaOvnUTXeBQ47W+kO/EFj5BR+Af1g0VVO6TeC3zhvnN0M/3MLFpo3c8QiPZ+HxMng8gdNZOF0GpxM4m4WzZXA2gfNZOF8G5xN4MgtPlsGTCVzMwsUyuJjA01l4ugyeTuByFi6XweX9bVrp8HS3z18aPcb/mxieRid9m0vX5ifd9I3sCtLX9FWtwJvb8YgA0F7syxyI57xo1WMw7Ydhg7LIZ5aOZk+6rYv8+lLnRhU+m3SYR/Kf88hmrVTjvIEtp5Fx1k3b7Z9TdeZqcnPtPrR5R32o4QxfLuenm8DHPsK3ifYav/sWQb60sbA7JhFZ+ZJjn1se6jZa2S3xuU2Wl+SQ143UJPXWpAjJW7SlvMXevKWh3UFX7g7mcytD3cYru6U+tyQKKUq6paJMvEVJSEji4i0ljvkTF4c2CF+5QRKvXRpql61sl3vtspCy5FsqS+EvSx6SOLalxHF/4pLQBhErN0jqtStC7SYr2xVeu2lIWYotlaX0l6UMSVyypcSldjtGv6Gi7aF2BBMcY/KGd/Ab84ei8GMVG9eskg9FceIUByWcSsdPrSL0IeFv5KS0kjhJ4ueOXotBwyLrtYvfB4ZR89yT2PW018JqGxSOoztVwhmf/zTG6BNuzV0VT2LJpOQsjoRg8H3/F95cfAk=

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2839
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by boskid »

Can you provide a save file that shows this issue? This is highly unbelievable for me because the only difference between sorting ascending and descending is the compare function but the code under the hood that picks a specific signal uses standard c++ function so the chance of an error here are basically 0. I need to rule out player errors in this specific case because i see lab tiles which suggests an editor may be used and there is a common trap in this case where a time is paused. Also a log file could help if by any chance this is a platform specific issue (which would be even more unlikely)

teiriko
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Oct 27, 2024 8:16 am
Contact:

Re: [boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by teiriko »

I've attached the log and the save file I've just created

Some notes:
- I'm using a MacBook with M1 Pro
- I've created a clean new game and used `/cheat` to get the items
- I've pasted the blueprint attached to the first message - got the same result
Attachments
selector_combinator_bug.zip
(1.87 MiB) Downloaded 14 times
factorio-current.log
(7.43 KiB) Downloaded 10 times

teiriko
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sun Oct 27, 2024 8:16 am
Contact:

Re: [boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by teiriko »

I've tried to do exactly the same on my Windows machine - and couldn't reproduce

Quezler
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

Re: [boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by Quezler »

can confirm on my m1 mac:
Attachments
Screenshot 2024-10-29 at 22.02.52.png
Screenshot 2024-10-29 at 22.02.52.png (811.4 KiB) Viewed 1334 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2839
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.12] Selector combinator returns wrong signal for the given index when choosing "sort ascending"

Post by boskid »

Ok, this issue was identified and is now fixed for 2.0.13.

This issue boils down to a c++ comparators, in this case the comparator used by selector combinator when comparing signal with itself would say it is lower and this apparently broke the underlying function that selects nth_element, but this issue only happened on mac since the nth_element function is provided by the library that comes with c++ compiler and it looks the standard library that comes with compiler on mac may perform the self compares which was giving wrong values causing wrong sorting order. On windows and linux the specific implementation must have been different as it was not doing self compares and the issue was not reproducible there.


Post Reply

Return to “Resolved Problems and Bugs”