This seems like a new variant of shmat-related bug reports on valgrind. I tested with valgrind 3.9.0 and 3.8.1. Both cause EINVAL error if a user code calls shmat with SHM_HUGETLB parameter to use hugepages. If the user code doesn't have SHM_HUGETLB option or runs it without valgrind, it goes fine. int main(int argc, char **argv) { int shmid = ::shmget( ::getpid(), 1ULL << 21, // IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); // <-- this works fine IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR | SHM_HUGETLB); // <-- This causes EINVAL if (shmid == -1) { std::cerr << "shmget failed!" << "[Errno " << errno << "] " << std::strerror(errno) << std::endl; return 1; } else { std::cout << "shmget() ok" << std::endl; } void* block = ::shmat(shmid, NULL, 0); if (block == ((void*) -1)) { std::cerr << "shmat failed!" << "[Errno " << errno << "] " << std::strerror(errno) << std::endl; ::shmctl(shmid, IPC_RMID, NULL); return 1; } else { std::cout << "shmat() ok" << std::endl; } ::shmdt(block); ::shmctl(shmid, IPC_RMID, NULL); return 0; } My environment is Fedora 19, x86_64. Reproducible: Always Steps to Reproduce: 1. Sample code above 2. 3. Actual Results: EINVAL error at shmat Expected Results: Should work fine.
Bug is fixed in revision 14683 or rather, this revision ensures that SHM_HUGETLB flag is ignored. A warning is given (once) to the user if such a flag is ignored
Thanks for the fix. Yes, ignoring SHM_HUGETLB is sufficient for my usecase (and probably everyone's, who cares TLB performance in valgrind runs). Is it in 3.10.0 release?
(In reply to Hideaki Kimura from comment #2) > Thanks for the fix. Yes, ignoring SHM_HUGETLB is sufficient for my usecase > (and probably everyone's, who cares TLB performance in valgrind runs). > Is it in 3.10.0 release? It is in the SVN version (the future 3.11.0).