In all but the most highly deployed platforms, it will be reentrant. You mention SIGSEGV, so I assume this is not one of them. In this case, most likely, memcpy () is not the culprit: this is the caller's error. If you ask memcpy () to copy bad pointers (or bad length), then this will be an error. You can easily do this:
memcpy(NULL, NULL, 123456789);
This will call SIGSEGV and it will tell you that memcpy () called it. Of course, this is not a memcpy fault - it is just what you said. Your signal handler is causing something strange. The return path (in gdb or any other tool that you have) to the caller’s website should show what you called it with. Otherwise, just print the arguments you pass memcpy.
source
share