AddressSanitizer memcpy-param-overlap errors with std::string with visual studio 2019

Pradeep K 1 Reputation point
2023-01-09T07:13:12.267+00:00

I'm using address sanitizer (ASAN) with visual studio 2019 (version 16.9.2) on windows.
ASAN is reporting lots of errors and almost all of them are memcpy-param-overlap.
They are related usage of std::string.

==13388==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x2141a3ba,0x2141a3cb) and [0x2141a3b0, 0x2141a3c1) overlap  
    #1 0x16d3e32 in std::basic_string<char,std::char_traits<char>,std::allocator<char> >::insert C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:3006  
    #2 0x16ae413 in std::operator+<char,std::char_traits<char>,std::allocator<char> > C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:4346  

Here is another instance

==13388==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x214239ba,0x214239cb) and [0x214239b0, 0x214239c1) overlap  
    #1 0x16d3e32 in std::basic_string<char,std::char_traits<char>,std::allocator<char> >::insert C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:3006  
    #2 0x16ae413 in std::operator+<char,std::char_traits<char>,std::allocator<char> > C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:4346  

There are lots of these and all the errors are similar to above.
I don't know what I'm missing here. Is this related to std libraries.
Any hints/direction would be helpful.

Developer technologies | Visual Studio | Debugging
Developer technologies | C++
{count} votes

1 answer

Sort by: Most helpful
  1. YujianYao-MSFT 4,296 Reputation points Microsoft External Staff
    2023-01-11T08:59:32.7833333+00:00

    Hi @Pradeep K,

    This document mentions the error you encountered, I suggest you refer to the solution in it.

    Best regards,

    Elya


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.