I am developing an Android application using NDK. The application blows up with “SIGSEGV” error which I believe a segmentation fault error.
I looked at my code and I think memcopy and memmove might cause this error. I was wondering if there is a safe way to call these functions.
Also please let me know any well described NDK debugging tutorials or anything related. Thanks in advance.
The rule with those 2 is that you use memcpy when you’re copying a block of bytes from one place to another, and the source and destination don’t overlap. If they do overlap, you have to use memmove. However, using them incorrectly results in corrupted data, not segfaults. Segfaults happen when you try to read or write to a memory location that is invalid – its analogous to Java’s NullPointerException. You want to triple check that you have destination, source and size in the correct order. Beyond that, we’ll need to see some code.