-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Use constant strings to avoid use after free. #27980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Diagnostics] Use constant strings to avoid use after free. #27980
Conversation
Using std::string in the function signature copies the constant string into a stack allocated copy, which is the one referenced by the StringRef that DiagnosticInfo stores. when the stack is abandoned, the string seems to be modificed in VC++, which makes the test fail in Windows. Using const char * in the signature avoids the std::string creation, and StringRef will refer to the static data instead.
(testing locally at the same time) @swift-ci please test Windows platform |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this, sorry about the breakage @drodriguez !
@swift-ci please clean test Windows platform |
Is
a known error? Seems to be happening also in other PRs, so I doubt is related to this change. |
I'm seeing an error from the |
@swift-ci please smoke test linux platform |
1 similar comment
@swift-ci please smoke test linux platform |
@swift-ci please smoke test Linux platform |
@compnerd I'm pretty sure this is going to fail again, swiftlang/swift-package-manager#2394 should fix the swiftbench issue |
Please test with following PR: @swift-ci please smoke test Linux platform |
@swift-ci please smoke test Linux platform |
Using std::string in the function signature copies the constant string
into a stack allocated copy, which is the one referenced by the
StringRef that DiagnosticInfo stores. when the stack is abandoned, the
string seems to be modificed in VC++, which makes the test fail in
Windows.
Using const char * in the signature avoids the std::string creation, and
StringRef will refer to the static data instead.
Intreoduced in #27868 and started to fail in https://ci-external.swift.org/job/oss-swift-windows-x86_64/1790
/cc @owenv