Skip to content

seq: different output when comparing with GNU #5759

Open

Description

@sylvestre

Found with the seq fuzzer

$ ./target/debug/coreutils seq -80 18.333615880731813 8158 > a.txt
$ LANG=C /usr/bin/seq -80 18.333615880731813 8158 > b.txt
$  diff -u a.txt b.txt
--- a.txt       2023-12-31 16:35:42.919872401 +0100
+++ b.txt       2023-12-31 16:36:00.859817826 +0100
@@ -376,75 +376,75 @@
 6795.105955274429875
 6813.439571155161688
 6831.773187035893501
-6850.106802916625314
+6850.106802916625313
 6868.440418797357127
 6886.774034678088940
 6905.107650558820753
 6923.441266439552566
 6941.774882320284379
 6960.108498201016192
-6978.442114081748005
+6978.442114081748004
 6996.775729962479818
 7015.109345843211631
 7033.442961723943444
 7051.776577604675257
 7070.110193485407070
 7088.443809366138883
-7106.777425246870696
+7106.777425246870695
 7125.111041127602509
 7143.444657008334322
 7161.778272889066135
 7180.111888769797948
 7198.445504650529761
 7216.779120531261574
-7235.112736411993387
+7235.112736411993386
 7253.446352292725200
 7271.779968173457013
 7290.113584054188826
 7308.447199934920639
 7326.780815815652452
 7345.114431696384265
-7363.448047577116078
+7363.448047577116077
 7381.781663457847891
 7400.115279338579704
 7418.448895219311517
 7436.782511100043330
 7455.116126980775143
 7473.449742861506956
-7491.783358742238769
+7491.783358742238768
 7510.116974622970582
 7528.450590503702395
 7546.784206384434208
 7565.117822265166021
 7583.451438145897834
 7601.785054026629647
-7620.118669907361460
+7620.118669907361459
 7638.452285788093273
-7656.785901668825086
+7656.785901668825085
 7675.119517549556899
 7693.453133430288712
 7711.786749311020525
 7730.120365191752338
-7748.453981072484151
+7748.453981072484150
 7766.787596953215964
-7785.121212833947777
+7785.121212833947776
 7803.454828714679590
 7821.788444595411403
 7840.122060476143216
 7858.455676356875029
-7876.789292237606842
+7876.789292237606841
 7895.122908118338655
-7913.456523999070468
+7913.456523999070467
 7931.790139879802281
 7950.123755760534094
 7968.457371641265907
 7986.790987521997720
-8005.124603402729533
+8005.124603402729532
 8023.458219283461346
-8041.791835164193159
+8041.791835164193158
 8060.125451044924972
 8078.459066925656785
 8096.792682806388598
 8115.126298687120411
-8133.459914567852224
-8151.793530448584037
+8133.459914567852223
+8151.793530448584036

Probably the usual numerial computing issues

Activity

  1. samueltardieu commented on Jan 1, 2024

    @samueltardieu
    Contributor

    Yes, and uutils is more consistent than GNU coreutils here.

  2. drinkcat commented on Feb 26, 2025

    @drinkcat
    Collaborator

    Played a bit with coreutils on different architectures here: https://gist.github.com/drinkcat/04b193dce9429205db3a3ed8dca8a7e6

    Difference matrix follows:

    • There are 450 lines in the files
    • arm (32-bit) gives out totally different output (just a few numbers at the beginning are the same, 443/450 are different...)
    • 16 differences between amd64 coreutils and rust version (as we know from above).
    • Rust implementation on arm64 is consistent with arm64-v8, mips64le, ppc64le and s390x coreutils.
    X linux-386 linux-amd64 linux-amd64(RUST) linux-arm64-v8 linux-arm-v5 linux-arm-v7 linux-mips64le linux-ppc64le linux-s390x
    linux-386 0 0 16 16 443 443 16 16 16
    linux-amd64 0 0 16 16 443 443 16 16 16
    linux-amd64-rust 16 16 0 0 443 443 0 0 0
    linux-arm64-v8 16 16 0 0 443 443 0 0 0
    linux-arm-v5 443 443 443 443 0 0 443 443 443
    linux-arm-v7 443 443 443 443 0 0 443 443 443
    linux-mips64le 16 16 0 0 443 443 0 0 0
    linux-ppc64le 16 16 0 0 443 443 0 0 0
    linux-s390x 16 16 0 0 443 443 0 0 0

    I'm not sure what the objective is in terms on exact compability, but given that coreutils isn't consistent across architectures, I wonder if this is worth fixing, or if this is just something we can accept (and that no one would ever notice...).

  3. Maximkaaa commented on Jun 19, 2025

    @Maximkaaa
    Contributor

    Using a more extreme example:

    seq 0 0.111111111111111111111111111111111111111111111111 0.999999999999999999999999999999999999999999999999
    0.000000000000000000000000000000000000000000000000
    0.111111111111111111109605274760436799397211871110
    0.222222222222222222219210549520873598794423742220
    0.333333333333333333315263297125241592766542453319
    0.444444444444444444438421099041747197588847484440
    0.555555555555555555561578900958252802411152515560
    0.666666666666666666630526594250483185533084906638
    0.777777777777777777753684396166988790355389937758
    0.888888888888888888876842198083494395177694968879
    1.000000000000000000000000000000000000000000000000
    
    $ cargo run seq 0 0.111111111111111111111111111111111111111111111111 0.999999999999999999999999999999999999999999999999
    0.000000000000000000000000000000000000000000000000
    0.111111111111111111111111111111111111111111111111
    0.222222222222222222222222222222222222222222222222
    0.333333333333333333333333333333333333333333333333
    0.444444444444444444444444444444444444444444444444
    0.555555555555555555555555555555555555555555555555
    0.666666666666666666666666666666666666666666666666
    0.777777777777777777777777777777777777777777777777
    0.888888888888888888888888888888888888888888888888
    0.999999999999999999999999999999999999999999999999
    

    I would argue that in this case any user would expect the second output and not the first.

    The only question is are there existing scripts that rely on incorrect behavior of GNU implementation for some reason, The Hyrum's Law states that there must be such scripts...

  4. drinkcat commented on Jun 19, 2025

    @drinkcat
    Collaborator

    Yeah, I documented some of this here: https://github.com/uutils/coreutils/blob/main/docs/src/extensions.md , but we could expand further, comments welcome. Also note that GNU coreutils documentation makes no guarantee (https://www.gnu.org/software/coreutils/manual/coreutils.html#seq-invocation), and that the behaviour is different on various architectures.

    It's not completely impossible that somebody out there relies on seq to round numbers to 80-bit floats (on x86), but... well... I don't think it's terribly valuable to replicate that behaviour. And nothing prevent GNU coreutils to switching to arbitrary precision decimal numbers as well in a future version, that'd break those users.

  5. drinkcat commented on Jun 19, 2025

    @drinkcat
    Collaborator

    Oh, IMHO the thing that makes this issue worth keeping open is to find a way to get the fuzzer to ignore those rounding errors... We'd still want to test varied parameters (rounding behaviour is tricky for example), but we need to ignore those least significant digits errors.

  6. mrudat commented on Nov 4, 2025

    @mrudat

    Given that I just spent some time looking at this, and seq currently (at least in the main branch) uses arbitrary-precision arithmetic... It looks like this isn't a bug anymore?

  7. eylulseyit commented on Oct 15, 2026

    @eylulseyit
    Contributor

    Hi, I read through the thread, and I agree with @drinkcat’s comment from June 2025. So the remaining work seems to be making fuzz_seq ignore small differences in the last digits, while still comparing the number of lines, the format and the exit code exactly. Once that works, fuzz_seq could be changed from false to true in fuzzing.yml. Would that be enough to close this issue and #7186? If so, I’d like to work on it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions