Hi

In my code i use memcpy to copy data between two arrays of unsigned char:
   memcpy(pNew, pDataPiece, iBlockSize);

iBlockSize has the correct size (197) which i used to create pDataPiece

In valgrind i get the following error:

==11456== Invalid read of size 8
==11456==    at 0x6CCD810: __memcpy_ssse3_back (in /lib64/libc-2.14.1.so)
==11456==    by 0x551FB6: AgentDataCollection::addData(unsigned short,
char const*, unsigned long, std::map<std::pair<unsigned short,
unsigned short>, std::vector<std::pair<unsigned long, unsigned char*>,
std::allocator<std::pair<unsigned long, unsigned char*> > >,
std::less<std::pair<unsigned short, unsigned short> >,
std::allocator<std::pair<std::pair<unsigned short, unsigned short>
const, std::vector<std::pair<unsigned long, unsigned char*>,
std::allocator<std::pair<unsigned long, unsigned char*> > > > > >&,
bool) (AgentDataCollection.cpp:453)
==11456==    by 0x4EF8D7: TDMaster::loadAgents(char const*) (TDMaster.cpp:1107)
==11456==    by 0x4F0D59: TDMaster::loadCurrentPops(float) (TDMaster.cpp:1479)
==11456==    by 0x4ECCF0: TDMaster::init(int, char**) (TDMaster.cpp:306)
==11456==    by 0x4E7A0E: main (TDMain.cpp:135)
==11456==  Address 0x112d36b0 is 192 bytes inside a block of size 197 alloc'd
==11456==    at 0x4C291C9: operator new[](unsigned long)
(vg_replace_malloc.c:305)
==11456==    by 0x5A49BA: PopReader::asc2Data(char*) (PopReader.cpp:115)
==11456==    by 0x5A5868: PopReader::readData() (PopReader.cpp:405)
==11456==    by 0x4EF83A: TDMaster::loadAgents(char const*) (TDMaster.cpp:1098)
==11456==    by 0x4F0D59: TDMaster::loadCurrentPops(float) (TDMaster.cpp:1479)
==11456==    by 0x4ECCF0: TDMaster::init(int, char**) (TDMaster.cpp:306)
==11456==    by 0x4E7A0E: main (TDMain.cpp:135)

(in addData i call memcpy, and not __memcpy_ssse3_back)

The same happens in a line like this
    sVal = sArg.substr(pos+1);
(where sVal and sArg are std::strings)
Here the complaint is:
 Address 0xa331ad8 is 0 bytes after a block of size 264 alloc'd

I have a similar message where  __memmove_ssse3_back makes an invalid
read 200 bytes inside a block of size 205
However there i don't know the details because it happens inside an
MPI function (MPI_Send), but the block size 205 is correct
and is also what i pass to MPI_Send.

How come a read of size 8 is made, when i actually copy 197 (or 205)?
Do i have to copy multiples of 8 to make memcpy and/or memmove happy?


Thank You
  Jody

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to