-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fixes va_list in strbuf being left uninitialized (causes MSVC to crash) #98
Fixes va_list in strbuf being left uninitialized (causes MSVC to crash) #98
Conversation
Naios
commented
Sep 17, 2023
- Ref Implement a world-local component id caching API and make use of it in cpp components flecs#1036
Thanks for the PR! |
I reverted the change as it caused the build to fail on gcc: https://github.com/SanderMertens/bake/actions/runs/6228764312 Are you sure this is necessary? The same code in Flecs works on msvc: https://github.com/SanderMertens/flecs/blob/master/src/datastructures/strbuf.c#L491 |
@SanderMertens sorry for the inconvenience, but I stil think that if it does not works this way I suggest that you make the function itself with variadic arguments (add an ellipsis) and just never add arguments and initialize the va_list correctly based on the ellipsis. I googled it quickly and it seems there is no proper way of doing it, also you cannot just return it from inside another function since after creation the va_list must be correctly destroyed in the same scope. Btw. is also seems like clang has an analysis pass for detecting uninitialized va_args so this is definitly not valid not to initialize it: https://chromium.googlesource.com/external/github.com/llvm-mirror/clang/+/refs/heads/master/test/Analysis/valist-uninitialized.c#18 |
Do you remember the scenario in which the code crashed? The uninitialized va_list shouldn't actually be used by the function it's passed into for that specific set of arguments ( |
It crashes deterministically on this revision so I can provide you a stacktrace:
Independently of its use-case it is very clear to me that the |
As long as the variable isn't used, it doesn't have to be initialized, and in this case it's not used. The line it's crashing on in the stack trace is not reading the va_list, it's just passing it as argument. How are you getting this to crash? I run bake in CI on Windows on every flecs commit and have never seen a crash. |
Did you compile with |
|
If All bake installations use debug mode. |