-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
protoc AddressSanitizer: new-delete-type-mismatch #20171
Comments
Is it possible that part of your binary is built with ASAN while part of it is not? I suspect that this is probably happening and causing the errors. From what I understand, ASAN changes ABI, and so you can't safely build for ASAN unless you do it for the entire binary. |
I really doubt it - vcpkg building protobuf with cmake, and in cmake cache (config-x64-windows-sanitizer-dbg-CMakeCache.txt.log) I see global flags
and protoc works properly when I disable this particular check in asan with
|
Maybe because it deallocates less bytes than allocated it is not leading to anything bad in non asan builds, but it still does not look ok. |
Actually from looking more closely at the stack trace, I think there is a different problem which is that the binary is mixing code from |
that's how vcpkg works. it builds ports in buildtree, then install them in package, then copy package to installed - and tools are used from installed after that - buildtree can be deleted after build - errors happens not in protobuf build, but in grpc build when it trying to use installed protoc for generation
|
I'm not very familiar with vcpkg, but from the stack trace it looks like it's getting some parts of libprotobuf from an installed DLL and other parts from a buildtree. I'm pretty sure that means something is going wrong, because that implies ODR violations from having two separate copies of libprotobuf. It could be that I'm misinterpreting the stack trace--maybe everything is actually in However, I remain suspicious that the problem is with the build setup rather than the code per se. Protoc is pretty well battle-tested, so it seems unlikely (though not impossible) that it would have serious memory management errors like the ones in the ASAN errors above. With those kind of errors it would also be surprising that protoc worked correctly with ASAN disabled. |
protoc and all it dependencies are in C:\vcpkg\installed\x64-windows-sanitizer\tools\protobuf, you see C:\vcpkg\buildtrees\protobuf\src\v5.29.3-6c24724110.clean in stack trace because that where source were located during build, the same way as you see D:\a_work\1\s\src\vctools\asan\llvm\compiler-rt\lib\asan\asan_win_new_scalar_thunk.cpp - that's where Visual Studio sources were located when Microsoft was building Visual Studio, there is no mix up of build options or libraries in this case |
I used docker image to test commands reproducing issue and that container is gone, so you can see small differences in logs in comments vs initial description.
here link command from build log install-x64-windows-sanitizer-dbg-out.log
If you want I can repeat docker build and attach all logs or even whole vcpkg directory, but it will be huge |
How to reproduce in windows docker (Visual Studio 2022 v17.12.4 atm)
and check |
I've replaced protoc binary with non sanitized version, and errors still there, so there is a good chance that errors are coming from grpc plugin and not from protoc itself, I'll try to confirm that tomorrow |
I see what is happening, in
MessageLite allocated as ::operator new(allocation_size_), but then deleted by typed delete in
(message_value is
I'm able to build protobuf and grpc with sanitizer, comment says that operator delete does not work for VS, but I'm targeting only VS 2022 and it is working for me there. |
@isanych - can you turn your patch into a PR so that we can run it in CI? |
@JasonLunn, created #20245 |
What version of protobuf and what language are you using?
Version: v5.29.3
Language: C++
What operating system (Linux, Windows, ...) and version?
Windows 11 24H2 and Windows Server 2022
What runtime / compiler are you using (e.g., python version or gcc version)
Visual Studio 2022 v17.12.4 and v17.8.8 with address sanitizer enabled
What did you do?
Steps to reproduce the behavior:
What did you expect to see
What did you see instead?
and in C:\vcpkg\buildtrees\grpc\install-x64-windows-sanitizer-dbg-out.log multiple sanitizer errors:
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
I can workaround asan errors with
but such protoc would require similar workarounds when used, so better workaround is to replace protoc binary with statically linked protoc without sanitizer.
The text was updated successfully, but these errors were encountered: