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

AddressSanitizer error example #2518

Closed
ncnnnnn opened this issue Oct 18, 2022 · 3 comments
Closed

AddressSanitizer error example #2518

ncnnnnn opened this issue Oct 18, 2022 · 3 comments

Comments

@ncnnnnn
Copy link

ncnnnnn commented Oct 18, 2022

run example with AddressSanitizer
vcpkg install spdlog
(compiler: vs2022, WIN10. spdlog 1.10.0)

err:

[2022-10-18 08:55:30.371] [info] Welcome to spdlog version 1.10.0  !
[2022-10-18 08:55:30.374] [warning] Easy padding in numbers like 00000012
[2022-10-18 08:55:30.375] [critical] Support for int: 42;  hex: 2a;  oct: 52; bin: 101010
[2022-10-18 08:55:30.376] [info] Support for floats 1.23
[2022-10-18 08:55:30.376] [info] Positional args are supported too..
[2022-10-18 08:55:30.377] [info]    right aligned, left     aligned
[2022-10-18 08:55:30.377] [debug] This message should be displayed..
[08:55:30 +08:00] [I] [thread 17120] This an info message with custom format
[2022-10-18 08:55:30.379] [info] ****************** Backtrace Start ******************
[2022-10-18 08:55:30.379] [debug] Backtrace message 90
[2022-10-18 08:55:30.379] [debug] Backtrace message 91
[2022-10-18 08:55:30.379] [debug] Backtrace message 92
[2022-10-18 08:55:30.379] [debug] Backtrace message 93
[2022-10-18 08:55:30.379] [debug] Backtrace message 94
[2022-10-18 08:55:30.379] [debug] Backtrace message 95
[2022-10-18 08:55:30.379] [debug] Backtrace message 96
[2022-10-18 08:55:30.379] [debug] Backtrace message 97
[2022-10-18 08:55:30.379] [debug] Backtrace message 98
[2022-10-18 08:55:30.379] [debug] Backtrace message 99
[2022-10-18 08:55:30.385] [info] ****************** Backtrace End ********************
=================================================================
==18348==ERROR: AddressSanitizer: container-overflow on address 0x0057f015f240 at pc 0x7fffdf3b44db bp 0x0057f015f050 sp 0x0057f015e7d0
READ of size 16 at 0x0057f015f240 thread T0
    #0 0x7fffdf3b4508  (Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\clang_rt.asan_dbg_dynamic-x86_64.dll+0x180044508)
    #1 0x7ff8851f2857 in std::_Char_traits<char, int>::move(char *const, char const *const, unsigned __int64) Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\xstring:117
    #2 0x7ff8851880ad in std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>::_Construct<2, char const *>(char const *const, unsigned __int64) Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\xstring:2718
    #3 0x7ff8851c51bb in std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>(class std::basic_string<char, 
struct std::char_traits<char>, class std::allocator<char>> const &) Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\xstring:2587
    #4 0x7ff885204d54 in spdlog::stdout_color_mt<struct spdlog::synchronous_factory>(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> const &, enum spdlog::color_mode) E:\dev\vcpkg\buildtrees\spdlog\src\v1.10.0-3cbe543323.clean\include\spdlog\sinks\stdout_color_sinks-inl.h:18
    #5 0x7ff6614d11d3 in stdout_logger_example(void) \spdlog\example\example.cpp:113
    #6 0x7ff6614d5e4b in main \spdlog\example\example.cpp:71
    #7 0x7ff6615bdd18 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    #8 0x7ff6615bdc6d in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #9 0x7ff6615bdb2d in __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:330
    #10 0x7ff6615bdd8d in mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:16
    #11 0x7ff8a2be7033  (C:\WINDOWS\System32\KERNEL32.DLL+0x180017033)
    #12 0x7ff8a41c26a0  (C:\WINDOWS\SYSTEM32\ntdll.dll+0x1800526a0)

Address 0x0057f015f240 is located in stack of thread T0 at offset 48 in frame
    #0 0x7ff6614d108f in stdout_logger_example(void) \spdlog\example\example.cpp:111

  This frame has 2 object(s):
    [32, 72) 'compiler temporary' <== Memory access at offset 48 is inside this variable
    [48, 64) 'console' <== Memory access at offset 48 is inside this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp, SEH and C++ exceptions *are* supported)
HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_container_overflow=0.
If you suspect a false positive see also: https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow.
SUMMARY: AddressSanitizer: container-overflow (\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\clang_rt.asan_dbg_dynamic-x86_64.dll+0x180044508)
Shadow bytes around the buggy address:
  0x01a4afcabdf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x01a4afcabe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x01a4afcabe10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x01a4afcabe20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x01a4afcabe30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x01a4afcabe40: 00 00 f1 f1 f1 f1 00 00[fc]00 00 f2 f2 f2 f2 00
  0x01a4afcabe50: 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00
  0x01a4afcabe60: 00 00 00 00 f1 f1 f1 f1 f8 f8 f8 f8 f8 f2 f2 f2
  0x01a4afcabe70: f2 f8 f8 f8 f8 f8 f2 f2 f2 f2 00 00 00 00 00 00
  0x01a4afcabe80: 00 00 f2 f2 f2 f2 f8 f2 f8 f2 f8 f2 f8 f8 f2 f2
  0x01a4afcabe90: f2 f2 f8 f2 f8 f8 f2 f2 f2 f2 f8 f2 f8 f8 f2 f2
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==18348==ABORTING
@gabime
Copy link
Owner

gabime commented Oct 18, 2022

seems like false positive unless msvc string’s move is broken which I very much doubt.

@gabime gabime closed this as completed Oct 18, 2022
@zchrissirhcz
Copy link

Hi, @ncnnnnn , I meet another crash of spdlog with VS2022 (pasted in #2902), which is a little bit similar with yours.

I think @gabime previously gives a short answer, and I would like to paste some of my thought, maybe it can be helpful.

Visual Studio 2022 has its concrete version, say, "17.2.0", "17.10.3", etc.

VS2022 17.2.0 is released in 2022.05.10, https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-2-is-now-available/ , which is the starting version that introduce "Address Sanitizer Error: Container overflow" for std::vector type. You may use _DISABLE_VECTOR_ANNOTATION to toggle VS's behaviour.

The date when you create this issue is "Oct 18, 2022", it's possible that you were using a VS2022 >= 17.2.0 version.

@zchrissirhcz
Copy link

@ncnnnnn I think to investigate your crash when enable ASAN, build spdlog from source, instead of using vcpkg's, can help us find the root of that error.

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