memcpy(3) && memmove(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

We have a huge client/server application, mostly written in C. We moved
now with it for the first time to 64-bit Linux (SuSE SLES 12 x86_64) and
compiled with gcc 4.9.2, but with -m32 (because we have to support also
32-bit customers). The historical (20++ years) grown code was full of
memcpy(3) calls, sometimes for overlapping memory, which is prohibited
by the man page of memcpy(3), of course, and we got what we deserve:
corrupted memory in destination of the copy. We nailed it down,
substituted memcpy(3) by memmove(3) and all is fine.

What me motivates to this posting is:

Why the (wrong) usage of memcpy(3) did not showed up on SLES 11 and/or
32bit?

What is the exact problem with memcpy(3) prohibiting the overlapping
memory,?

And, last but not least: Why we have memcpy(3) at all, if memmove(3)
gives the same result and is thread-safe too? For example, on my beloved
FreeBSD memcpy(3) is implemented as bcopy(3), I checked the code for it,
and allows even overlapping memory.

Thx
	matthias
-- 
Matthias Apitz, ✉ guru@xxxxxxxxxxx, ⌂ http://www.unixarea.de/  ☎ +49-176-38902045



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux