danmar / simplecpp

C++ preprocessor
BSD Zero Clause License
209 stars 83 forks source link

MSVC with address sanitizer activated crashes #304

Closed mgerhardy closed 1 month ago

mgerhardy commented 1 year ago
[build]   Address 0x12b7dc2f5198 is a wild pointer inside of access range of size 0x000000000008.
[build]   SUMMARY: AddressSanitizer: unknown-crash C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\xstring:2294 in std::_String_val<struct std::_Simple_types<char>>::_String_val<struct std::_Simple_types<char>>(void)
[build]   Shadow bytes around the buggy address:
[build]     0x048ed65de9e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65de9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea20: 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
[build]   =>0x048ed65dea30: 00 00 00[07]00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea40: 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea60: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00
[build]     0x048ed65dea70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]     0x048ed65dea80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[build]   Shadow byte legend (one shadow byte represents 8 application bytes):
[build]     Addressable:           00
[build]     Partially addressable: 01 02 03 04 05 06 07 
[build]     Heap left redzone:       fa
[build]     Freed heap region:       fd
[build]     Stack left redzone:      f1
[build]     Stack mid redzone:       f2
[build]     Stack right redzone:     f3
[build]     Stack after return:      f5
[build]     Stack use after scope:   f8
[build]     Global redzone:          f9
[build]     Global init order:       f6
[build]     Poisoned by user:        f7
[build]     Container overflow:      fc
[build]     Array cookie:            ac
[build]     Intra object redzone:    bb
[build]     ASan internal:           fe
[build]     Left alloca redzone:     ca
[build]     Right alloca redzone:    cb
[build]   ==24628==ABORTING
[build]       #0 0x7ff655ed843a in std::_String_val<struct std::_Simple_types<char>>::_String_val<struct std::_Simple_types<char>>(void) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\xstring:2294
[build]       #1 0x7ff655ed8fc5 in std::_Compressed_pair<std::allocator<char>,std::_String_val<std::_Simple_types<char> >,1>::{ctor} C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\xmemory:1520
[build]       #2 0x7ff655ed8fc5 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 &) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\xstring:2491
[build]       #3 0x7ff655f3e130 in simplecpp::Token::Token(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>, class simplecpp::Location const &) C:\Users\marti\dev\engine\contrib\libs\simplecpp\simplecpp.h:105
[build]       #4 0x7ff655f17405 in simplecpp::TokenList::readfile(class std::basic_istream<char, struct std::char_traits<char>> &, class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> const &, class std::list<struct simplecpp::Output, class std::allocator<struct simplecpp::Output>> *) C:\Users\marti\dev\engine\contrib\libs\simplecpp\simplecpp.cpp:730
[build]       #5 0x7ff655f145ab in simplecpp::TokenList::TokenList(class std::basic_istream<char, struct std::char_traits<char>> &, class std::vector<class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>>, class std::allocator<class std::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 &, class std::list<struct simplecpp::Output, class std::allocator<struct simplecpp::Output>> *) C:\Users\marti\dev\engine\contrib\libs\simplecpp\simplecpp.cpp:236

the flags I set

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /nologo /Zi /fsanitize=address /RTC1 /W4 /DEBUG /wd4324")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /nologo /Zi /fsanitize=address /RTC1 /W4 /DEBUG /wd4324")

and I build in release mode

firewave commented 1 year ago

Thanks for your report. Please also provide a sample to reproduce the issue with.

firewave commented 1 month ago

Closing as no code for reproduction has been provided.