Interrupted system call for posix_memalign

2019-09-05 06:34发布

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

Thanks in advance.

2条回答
时光不老,我们不散
2楼-- · 2019-09-05 06:46

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.

查看更多
SAY GOODBYE
3楼-- · 2019-09-05 06:52

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
查看更多
登录 后发表回答