|
From: jody <jod...@gm...> - 2012-06-12 14:23:33
|
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
|
|
From: jody <jod...@gm...> - 2012-06-12 14:45:08
|
Additional piece of strangeness:
When i copy the same data to different buffer just before the
offending memcpy,
valgrind does not complain:
unsigned char *pTest2 = new unsigned char[iBlockSize];
// no complaint here:
memcpy(pTest2, pDataPiece, iBlockSize);
// yes complaint here:
memcpy(pNew, pDataPiece, iBlockSize); pNew += iBlockSize;
This is strange for me, beause it is about reading (i.e. pDataPiece) and not
about writing (i.e. pTest2 or pNew)
I'm very confused.
Is there an explanation?
Thank You
Jody
On Tue, Jun 12, 2012 at 4:23 PM, jody <jod...@gm...> wrote:
> 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
|
|
From: Julian S. <js...@ac...> - 2012-06-12 14:54:07
|
> ==11456== Invalid read of size 8 > ==11456== at 0x6CCD810: __memcpy_ssse3_back (in /lib64/libc-2.14.1.so) You need to use a newer version of valgrind that handles this function properly. I suspect you are using an old version of Valgrind. J |
|
From: Brian B. <bri...@gm...> - 2012-06-12 14:58:15
|
This is fixed in newer Valgrind. |
|
From: jody <jod...@gm...> - 2012-06-12 15:25:46
|
Thank You for the information! I am using valgrind 3.6.1-r3 (newest gentoo ebuild) Jody |
|
From: jody <jod...@gm...> - 2012-06-13 13:58:04
|
Yes, i already did that (downloaded and built the tarball from the Valgrind site) - and now the memcpy messages have disappeared. Thanks again Jody On Wed, Jun 13, 2012 at 10:04 AM, Igmar Palsenberg <ig...@pa...> wrote: > > >> Thank You for the information! >> I am using valgrind 3.6.1-r3 (newest gentoo ebuild) > > This version was released over 1.5 years ago. 3.7.0 is current, but you might want to build your own from svn. > > > > Igmar |