Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-96399

NumberParser relies on strtod, making it potentially unreliable as-is

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • ALL
    • Programmability 2024-11-11, Programmability 2024-11-25

      See comment and demo code in SERVER-96176.

      https://jira.mongodb.org/browse/SERVER-96176?focusedCommentId=6818343&focusedId=6818343&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-6818343

      strtod relies on C locale. This means that its interpretation of numeric formatting can vary from user to user if we accept global locale changes. In the default "C" locale we're fine. We just have to make sure we never change it, e.g. via a setlocale(LC_ALL, "") call. This would a user-friendly thing to do but will screw up our processing.

      It also relies on floating point rounding mode, which is another global setting we may or may not control.

      These two factors make strtod potentially risky, and we should not use it.
      We should switch to std::from_chars even if it's slow, at least it's correct.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: