Overloading can cause unexpected version of nsTSubString::AppendPrintf to be selected
Categories
(Core :: XPCOM, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox84 | --- | fixed |
People
(Reporter: bryce, Assigned: bryce)
References
Details
Attachments
(2 files)
Based on behaviour seen in bug 1673670 MSVC has some unexpected behaviour when dealing with overloads where both a printf and a vprintf style function are available (a reduced case can be seen at https://godbolt.org/z/MasGv4). Even though we use clang on Windows, we still use some parts of Microsoft's tooling which makes this an issue.
This means that nsTSubString::AppendPrintf[0] may be resolved unexpectedly when using a char array cast to a pointer (edit: or any non const char*). It's not clear to me if there are other cases that could trigger this, but it is desirable to avoid the footgun this presents.
The vprintf version of AppendPrintf is used at a relatively small number of call sites, so I think renaming the function to avoid overloading should be fairly painless. I'll look into doing so + getting some gtest coverage.
| Assignee | ||
Comment 1•5 years ago
|
||
This adds some coverage for nsTSubString::AppendPrintf. These tests will be
expanded in future patches, but this gives some baseline coverage. Importantly
for the bug at hand, this provides a test case that shows the unexpected
overload resolution on Windows.
| Assignee | ||
Comment 2•5 years ago
|
||
This patch also expands tests to check that the results of creating string via
both methods are consistent.
Depends on D95051
| Assignee | ||
Comment 3•5 years ago
|
||
Try push showing new tests providing coverage and getting weird on Windows https://treeherder.mozilla.org/#/jobs?repo=try&revision=f53d1c1a4ba56510ec8866d547e62d655e81689b&selectedTaskRun=dUsk3RSaTyirIuoo4UmjTQ.0
Comment 4•5 years ago
|
||
Other cases that might trigger this might only be on error/exceptional code paths, which are not covered by tests.
Comment 6•5 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/cafb95a0288b
https://hg.mozilla.org/mozilla-central/rev/eeb7837a1c06
Updated•5 years ago
|
Description
•