Interrupted system call for posix_memalign

2019-09-05 06:45发布

问题:

I am getting this exception with posix_memalign. Any idea as to why we get it?

Thanks in advance.

回答1:

Interrupted system calls are usually the result of a system call being interrupted. In other words, the process is receiving a signal while the call is executing.



回答2:

The issue is resolved: The thing is the alignment boundary should be a multiple of 2 and sizeof(void *). So if posinter size is 4 bytes, the second argument should be 4, 8, 16 etc. Instead of that i was putting it as only multiple of 2, and hence it was crashing.

Wrong usage: crashes
posix_memalign(&addr, 2, 8);

Correct usage:
 posix_memalign(&addr, 4, 8); // Second argument multiple of void* and 2