mini_installer with asan is broken due to missing dependencies |
||||
Issue descriptionThe mini_installer cannot be ASAN-instrumented on windows. The ASAN libraries are bringing some dependencies that are missing. Related to: https://bugs.chromium.org/p/chromium/issues/detail?id=598761 With this config: --- target_cpu = "x86" is_debug = false is_asan = true is_clang = true --- Output: --- D:\src\chromium\src>ninja -j1 -C out\asan ninja: Entering directory `out\asan' [1/1] Regenerating ninja files [1/10198] LINK mini_installer.exe mini_installer.exe.pdb FAILED: mini_installer.exe mini_installer.exe.pdb D:/src/depot_tools/python276_bin/python.exe gyp-win-tool link-wrapper environment.x86 False link.exe /nologo /OUT:./mini _installer.exe /PDB:./mini_installer.exe.pdb @./mini_installer.exe.rsp clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strlen referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strnlen referenced in func tion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strcmp referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strncmp referenced in func tion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strstr referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strchr referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strrchr referenced in func tion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strspn referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strcspn referenced in func tion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _strpbrk referenced in func tion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _memcmp referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _memchr referenced in funct ion "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _frexp referenced in functi on "void __cdecl InitializeCommonInterceptors(void)" (?InitializeCommonInterceptors@@YAXXZ) clang_rt.asan-i386.lib(asan_interceptors.cc.obj) : error LNK2019: unresolved external symbol _longjmp referenced in func
,
Aug 22 2016
,
Aug 22 2016
These 4 targets don't link locally, with missing symbols that should come from the CRT: remoting_host, remoting_console, remoting_desktop, mini_installer They all use /ENTRY: in ldflags to set a custom entry point. I guess /ENTRY: disables some linker magic that normally pulls in the right crt? Normally /MD or similary puts a .drectve section with /DEFAULTLIB:msvcrt.lib in each .obj file, but maybe /ENTRY makes link.exe ignore that?
,
Aug 22 2016
C:\src\chrome\src>type test.cc
#include <stdlib.h>
int main() { malloc(4);return 4; }
C:\src\chrome\src>cl /c test.cc
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
test.cc
C:\src\chrome\src>link test.obj
Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation. All rights reserved.
C:\src\chrome\src>link test.obj /ENTRY:main libcmt.lib
Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation. All rights reserved.
test.obj : error LNK2019: unresolved external symbol _malloc referenced in function _main
test.exe : fatal error LNK1120: 1 unresolved externals
,
Aug 22 2016
Err, last bit was supposed to say: C:\src\chrome\src>link test.obj /ENTRY:main Microsoft (R) Incremental Linker Version 14.00.23918.0 Copyright (C) Microsoft Corporation. All rights reserved. test.obj : error LNK2019: unresolved external symbol _malloc referenced in function _main test.exe : fatal error LNK1120: 1 unresolved externals
,
Aug 25 2016
So, do you think the solution is to add '#pragma comment(lib, "msvcrt")' to asan?
,
Aug 25 2016
I'm not sure does that do the right thing when the client program is built with all of /MT /MD etc? Also, does mainCRTStartup do crt initialization that's missing if we go through a different entry point?
,
Aug 25 2016
I think we have defines in ASan that tell us whether we expect to use this variant of the ASan runtime with /MT or /MD.
,
Aug 25 2016
What about initialization?
,
Jan 11 2017
As pointed out by Nico on #9, there is an issue with the initialization.
Here is an example:
[host.cc]
int *p = 0;
int main() {
*p = 42;
return 0;
}
int Entry() {
*p = 42;
return 0;
}
Compiled with:
% clang-cl.exe host.cc /c
Linked and executed with:
% link.exe host.obj
% link.exe host.obj /ENTRY:HostEntryPoint
As expected, both executable are crashing.
Compiled with: (adding sanitizer)
% clang-cl.exe host.cc /c -fsanitize=address
Linked with:
% link.exe host.obj ..\ninja\lib\clang\4.0.0\lib\windows\clang_rt.asan-i386.lib
The error is correctly detected:
=================================================================
==9800==ERROR: AddressSanitizer: access-violation on unknown address 0x00000000 (pc 0x011d1052 bp 0x003afb58 sp 0x003afb
48 T0)
==9800==The signal is caused by a WRITE memory access.
==9800==Hint: address points to the zero page.
#0 0x11d1051 (D:\src\llvm\examples\host.exe+0x401051)
#1 0x11f5029 in _sanitizer_print_stack_trace+0x91c9 (D:\src\llvm\examples\host.exe+0x425029)
#2 0x77403369 in BaseThreadInitThunk+0x11 (C:\Windows\syswow64\kernel32.dll+0x7dd73369)
#3 0x77939901 in RtlInitializeExceptionChain+0x62 (C:\Windows\SysWOW64\ntdll.dll+0x7dea9901)
#4 0x779398d4 in RtlInitializeExceptionChain+0x35 (C:\Windows\SysWOW64\ntdll.dll+0x7dea98d4)
BUT, when linked with the /ENTRY switch
% link.exe host.obj ..\ninja\lib\clang\4.0.0\lib\windows\clang_rt.asan_dynamic-i386.lib /ENTRY:Entry
Microsoft (R) Incremental Linker Version 14.00.23506.0
Copyright (C) Microsoft Corporation. All rights reserved.
host.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
**** The initializers are not executed! ****
I looked why this was not an issue with the chromium targets (i.e. remoting_console.exe). The target is loading an instrumentd DLL which is calling __asan_init (redirected to the main executable) on load time, before the ENTRY point is reached.
,
Jan 11 2017
I've made an alternative fix for the same bug (still few things to fix). But the idea is to avoid the 'code size' optimisation (using /ENTRY:) for these executables. see: https://codereview.chromium.org/2621223003/ This is fixing the initializers issue. But, the intrumented executable are slighty different because they are now linking with the CRT.
,
Jan 16 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02 commit 7a284fcc9ea22e8b6f3717fee7267a21f55e8a02 Author: etienneb <etienneb@chromium.org> Date: Mon Jan 16 18:42:36 2017 Fix building ASAN instrumented executables with custom entrypoints This is an alternative fix for https://codereview.chromium.org/2570153002/ As pointed by Nico, the previous patch may have issues with initializers. BUG= 636398 Review-Url: https://codereview.chromium.org/2621223003 Cr-Commit-Position: refs/heads/master@{#443926} [modify] https://crrev.com/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02/base/win/BUILD.gn [modify] https://crrev.com/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02/chrome/installer/mini_installer/BUILD.gn [modify] https://crrev.com/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02/chrome/installer/mini_installer/mini_installer.cc [modify] https://crrev.com/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02/remoting/host/win/BUILD.gn [modify] https://crrev.com/7a284fcc9ea22e8b6f3717fee7267a21f55e8a02/remoting/host/win/entry_point.cc
,
Mar 2 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by r...@chromium.org
, Aug 10 2016