Getting segmentation fault SIGSEGV in memcpy after mmap

前端 未结 4 1857
既然无缘
既然无缘 2021-01-23 16:50

I wrote a simple Android native function that get a filename and some more arguments and read the file by mmapping (mmap) it\'s memory.

Because it\'s mmap, I don\'t real

4条回答
  •  忘了有多久
    2021-01-23 17:29

    There is a big problem here:

        addr+=jbuffer_size;
    

    You're bumping addr by sizeof(int) * jbuffer_size bytes whereas you just want to increment it by jbuffer_size bytes.

    My guess is sizeof(int) is 4 on your system, hence you crash at around 25% of the way through your loop, because you're incrementing addr by a factor of 4x too much on each iteration.

提交回复
热议问题