-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[vcpkg-tool] Tool sometimes segfaults in manifest mode #26651
Comments
I think the reason for this is that How reliably can you reproduce the bug and what inputs do you use, i.e. what are the contents of your |
It's quite hard to reproduce. It happens maybe once or twice, but only on our CI, I'm not having any success reproducing it, otherwise I'd be able to attach a debugger. I've even tried to build vcpkg-tool with ASAN and TSAN enabled. Even like that, I couldn't trigger a failure. I added some logging to get the command that is executed, for me it's something like this:
|
I guess this is related to the second sub-item in #21905. |
@dg0yt @omartijn I think I found the reason for the crash: microsoft/vcpkg-tool#695 Because this is currently the only place where multithreading is in use, there should be no crashes anymore in CI. @omartijn Thanks again for providing debug information! |
The crash occurs in |
I did some further debugging and it seems like there is some null termination missing. The difficulty is to debug this issue as I don't have a Mac and the issue seems to depend on code generation because adding more print statements makes it disappear. Since the issue reproduces 100% in CI runs with the current setup @omartijn can you please try to debug this on your Mac using the linked PR branch (microsoft/vcpkg-tool#695)? That being said my new theory is that there is some wrong code generation/ optimization going on and that it is not caused by vcpkg. @BillyONeal What do you think about this? Is this issue worth adding fuzzing to it? |
Alright, with all the work you'd done to be able to explicitly trigger this bug, I managed to find a source of undefined behaviour. vcpkg-tool uses a What happens in that case is that a temporary
This way, it'll still work if there is an existing string, but not when a temporary is passed. This leads to many compile errors - which are all bugs triggering UB. |
cc @BillyONeal |
BTW: If I compile this example program: #include <string_view>
#include <string>
int main()
{
std::string_view bla = std::string{"Hello, world!"};
} and compile it with clang, even without specifying warning flags, I get the following warning:
which is really helpful in diagnosing this particular class of bug. This warning doesn't come when using the home-grown StringView class (and I don't think you can enable this for your own classes yet, unfortunately). I guess this class was made to avoid requiring c++17? Is that really important nowadays that the tool is provided pre-built to vcpkg? If so, could we maybe check whether c++17 is available and then simply alias |
Thanks a lot for reproducing and explaining the bug. It finally turns out that my initial guess that
C++ 17 is already in use. I really don't know why [To avoid any confusion: I'm not working for Microsoft] |
That's not true:
does not do that. (Both the materialized temporary
No, |
Standard references for the above:
|
Ah, you're right about that. So the issue is (luckily) confined to places where the The parser is then used a line later - in anothre full-expression - when the temporary is destructed. In this case, clang would've caught the bug had we used |
Describe the bug
On rare occasions vcpkg-tool will crash during a CMake configure. It crashes right after calculatng the installation plan in
popen
syscall, from what I can tell this is where it tries to restore packages from cache.Environment
To Reproduce
Steps to reproduce the behavior:
Expected behavior
vcpkg-tool should not crash
I've attached a crash log, it crashes in Thread 46 which does not really seem to start, it doesn't get to the
posix_spawn_file_actions_addclose
like the other threads. My gut feeling tells me that it's because one of the input arguments is bogus and it's trying to read invalid memory because of it.vcpkg-crash.txt
The text was updated successfully, but these errors were encountered: