Skip to content

Possible bug in DoubleParser.cs #7181

Closed

Description

@lopango

In Microsoft.ML.Core\Utilities\DoubleParser.cs near lines 143 and 195

            int ichEnd;
            if (!DoubleParser.TryParse(span.Slice(ich, span.Length - ich), out value, out ichEnd, flags))
            {
                value = default(Double);
                return Result.Error;
            }

            // Make sure everything was consumed.
            while (ichEnd < span.Length)
            {
                if (!char.IsWhiteSpace(span[ichEnd]))
                    return Result.Extra;
                ichEnd++;
            }

the ichEnd is indexed on the sliced span.
If ich is not 0 there will be an offset when for "ichEnd < span.Length" and "span[ichEnd]"

Example : for an input like " 1.234 " the method will return Result.Extra

Pössible solutions:

  • ichEnd += ich;
  • modify the tryparse to accept an offset and use the original span

Activity

  1. added
    area-CoreCore ML.NET APIs and shared functionality
    on Sep 8, 2026
  2. rosebyte commented on Oct 22, 2026

    @rosebyte
    Member

    Triage: there is a pr fixing this.

  3. added this to the ML.NET 7.0 milestone on Oct 22, 2026
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

    area-CoreCore ML.NET APIs and shared functionalitygreendevelopment

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions