Skip to content
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

Error in StringPrintfTest.Multibyte with Visual Studio 2019 16.4.1 x64 #7074

Closed
emmenlau opened this issue Jan 10, 2020 · 4 comments
Closed

Comments

@emmenlau
Copy link

When running the tests I get a reproducible assertion in StringPrintfTest.Multibyte on a Visual Studio 2019 16.4.1 x64 build. All other platforms (Ubuntu 18.04, CentOS 7.7, macOS XCode 9, Windows Visual Studio 2017.9) work fine with the same build instructions.

Version: v3.11.2
Windows 10, Visual Studio 2019 16.4.1 x64
CMake 3.16.1, Google Test 1.10.0

[...]
[ RUN      ] StringPrintfTest.Multibyte
1067 minkernel\crts\ucrt\src\appcrt\convert\mbstowcs.cpp(246) : Assertion failed: (pwcs == nullptr && sizeInWords == 0) || (pwcs != nullptr && sizeInWords > 0)
@emmenlau
Copy link
Author

Anyone?

@MCESoftwareLT
Copy link

I get the same Assertion.
protobuf-3.11.4
Visual Studio 2019 16.5.2 x86
CMake 3.17

@NouberNou
Copy link

I get the same assertion in VS 2015 on 3.2.0 and 3.3.0.

Did not get it in 2017.

@emmenlau
Copy link
Author

emmenlau commented Sep 2, 2020

I can still reproduce this issue with protobuf 3.13.0 in Visual Studio 2019 16.8 x64:


 [ RUN      ] StringPrintfTest.Multibyte
 minkernel\crts\ucrt\src\appcrt\convert\mbstowcs.cpp(246) : Assertion failed: (pwcs == nullptr && sizeInWords == 0) || (pwcs != nullptr && sizeInWords > 0)

Could this be looked at? It seems a bit scary if multi-byte character conversions are potentially broken...

florin-crisan added a commit to florin-crisan/protobuf that referenced this issue Jun 15, 2021
`setlocale` returns a pointer to a buffer containing the current locale name.
This needs to be copied into a `std::string` or it will be overwritten by the next call.

Trying to call `setlocale` with a non-null, invalid pointer can have unpredictable results, such as
```
[ RUN      ] StringPrintfTest.Multibyte
minkernel\crts\ucrt\src\appcrt\convert\mbstowcs.cpp(246) : Assertion failed: (pwcs == nullptr && sizeInWords == 0) || (pwcs != nullptr && sizeInWords > 0)
```

`setlocale` can also return a `nullptr` if it fails, but we assert against that.
florin-crisan added a commit to florin-crisan/protobuf that referenced this issue Jul 5, 2021
`setlocale` returns a pointer to a buffer containing the current locale name.
This needs to be copied into a `std::string` or it will be overwritten by the next call.

Trying to call `setlocale` with a non-null, invalid pointer can have unpredictable results, such as
```
[ RUN      ] StringPrintfTest.Multibyte
minkernel\crts\ucrt\src\appcrt\convert\mbstowcs.cpp(246) : Assertion failed: (pwcs == nullptr && sizeInWords == 0) || (pwcs != nullptr && sizeInWords > 0)
```

`setlocale` can also return a `nullptr` if it fails, but we assert against that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants