Skip to content

Instantly share code, notes, and snippets.

@pluswave
Created July 18, 2014 11:14
Show Gist options
  • Save pluswave/1503265e68c6c4443c70 to your computer and use it in GitHub Desktop.
Save pluswave/1503265e68c6c4443c70 to your computer and use it in GitHub Desktop.
odd SIGBUS
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int fileDescriptor;
int size = 4*1024*1024;
fileDescriptor = shm_open("/test", O_CREAT | O_CLOEXEC | O_RDWR, S_IRUSR | S_IWUSR);
ftruncate(fileDescriptor, size);
void* data = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0);
memset(data, 'a', size);
return 0;
}
@pluswave
Copy link
Author

OK it is a system integration issue, the tmpfs of /dev/shm has a mount option size=1M which can't have a 4M shared memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment