Bug #116594 [MSVC] MySQL failed to build with msvc on Windows when add ASAN option

Submitted: 8 Nov 2024 6:13 Modified: 26 Nov 2024 7:51
Reporter: Liu June Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:8.4, 8.0 OS:Windows
Assigned to: CPU Architecture:x86

[8 Nov 2024 6:13] Liu June
Description:
MySQL failed to build with msvc on Windows when add ASAN option due to below errors:

time_util.obj : error LNK2019: unresolved external symbol "class absl::lts_20230802::time_internal::cctz::time_zone __cdecl absl::lts_20230802::time_internal::cctz::utc_time_zone(void)" (?utc_time_zone@cctz@time_internal@lts_20230802@absl@@YA?AVtime_zone@1234@XZ) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::util::`anonymous namespace'::FormatTime(__int64,int)" (?FormatTime@?A0xd207e08b@util@protobuf@google@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_JH@Z) [C:\gitP\mysql\mysql-server\build_amd64\extra\protobuf\protobuf-24.4\libprotobuf.vcxproj]
  C:\gitP\mysql\mysql-server\build_amd64\library_output_directory\Release\libprotobuf.dll : fatal error LNK1120: 1 unresolved externals [C:\gitP\mysql\mysql-server\build_amd64\extra\protobuf\protobuf-24.4\libprotobuf.vcxproj]
  time_util.obj : error LNK2019: unresolved external symbol "class absl::lts_20230802::time_internal::cctz::time_zone __cdecl absl::lts_20230802::time_internal::cctz::utc_time_zone(void)" (?utc_time_zone@cctz@time_internal@lts_20230802@absl@@YA?AVtime_zone@1234@XZ) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::util::`anonymous namespace'::FormatTime(__int64,int)" (?FormatTime@?A0xd207e08b@util@protobuf@google@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_JH@Z) [C:\gitP\mysql\mysql-server\build_amd64\extra\protobuf\protobuf-24.4\libprotobuf.vcxproj]
  C:\gitP\mysql\mysql-server\build_amd64\library_output_directory\Release\libprotobuf.dll : fatal error LNK1120: 1 unresolved externals [C:\gitP\mysql\mysql-server\build_amd64\extra\protobuf\protobuf-24.4\libprotobuf.vcxproj]

How to repeat:
1. git clone https://github.com/mysql/mysql-server C:\gitP\mysql
2. Open VS2022 x64 Native Tools command.
3. set _CL_= /fsanitize=address /GS- /wd5072 & set _LINK_= /InferASanLibs 
4. mkdir C:\gitP\mysql\mysql-server\build_amd64 & cd /d C:\gitP\mysql\mysql-server\build_amd64
5. set PATH=C:\tools\msys64\usr\bin;%PATH%
6. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0  -DWITH_SSL=C:\gitP\Microsoft\vcpkg\installed\x64-windows ..
6. msbuild /p:Platform=x64 /p:Configuration=Release MySQL.sln /t:Rebuild
[11 Nov 2024 12:10] MySQL Verification Team
Hello Liu June,

Thank you for the report and feedback.
Observed this even with 8.0.40 build. 

regards,
Umesh
[21 Nov 2024 8:31] Tor Didriksen
Posted by developer:
 
--- a/extra/abseil/abseil-cpp-20230802.1/absl/time/internal/cctz/include/cctz/time_zone.h
+++ b/extra/abseil/abseil-cpp-20230802.1/absl/time/internal/cctz/include/cctz/time_zone.h
@@ -232,7 +232,7 @@ class time_zone {
 bool load_time_zone(const std::string& name, time_zone* tz);
 
 // Returns a time_zone representing UTC. Cannot fail.
-time_zone utc_time_zone();
+ABSL_DLL time_zone utc_time_zone();

This fixes it, but shouldn't really be necessary, since the 'absl_dll' library has property WINDOWS_EXPORT_ALL_SYMBOLS TRUE

Some of our .proto files generate ASAN warnings when running 'protoc' (no such problems on Linux with gcc/clang)
so this is needed during build:
export ASAN_OPTIONS="new_delete_type_mismatch=false"
[26 Nov 2024 7:51] Liu June
Thanks for the reply. 
I tried to add option /bigobj and set ASAN_OPTIONS=new_delete_type_mismatch=0 when build in ASAN mode, it built passed.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.055 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.