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

`fmt::formatter<HostAndPort>::format` returns wrong iterator

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.0-rc0, 4.7.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v4.4
    • Service arch 2020-04-20

      `fmt::formatter::format` writes into and advances an output iterator obtained by `ctx.out()`.  It has to return the advanced output iterator. But we return the `ctx.out()`, not the copy we advanced.

      This yielded UB in a toolchain validation build against mongo 4.2 on
      “Amazon Linux 1 2018.03" the build image.

      [https://logkeeper.mongodb.org/lobster/build/24a6f9b5ad70e8fbfc9bed6e0ccf388e/test/5e8a1e02be07c446740c1d7f#bookmarks=0%2C19%2C67

      ]
       

      [cpp_unit_test:network_test] 2020-04-05T18:05:54.634+0000 2020-04-05T18:05:54.634+0000 E - [main] Throwing exception: Expected fmt::format("{}", hp) == hps (1.2.3.4:2\0\0\0\0 == 1.2.3.4:27017) @src/mongo/util/net/hostandport_test.cpp:139
      
      [cpp_unit_test:network_test] 2020-04-05T18:05:54.634+0000 2020-04-05T18:05:54.634+0000 I - [main] FAIL: Fmt Expected fmt::format("{}", hp) == hps (1.2.3.4:2\0\0\0\0 == 1.2.3.4:27017) @src/mongo/util/net/hostandport_test.cpp:139 in test Fmt  

       
       

       

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

              Created:
              Updated:
              Resolved: