From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 Description of problem: I am unable to create posix message queues with a mq_maxmsg > 10. The default mq_open will open a queue of 10 messages of 8192 bytes. Queue lengths of 100 worked on previous versions of glibc. {{{ #include <stdio.h> #include <mqueue.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <sys/wait.h> #include <errno.h> #define NAMESIZE 50 #define QUEUESIZE 100 int main () { mqd_t myMq; struct mq_attr attr; struct mq_attr getattr; char qname[NAMESIZE]; sprintf(qname, "/mq_open_name_%d", getpid()); attr.mq_msgsize = 4; attr.mq_maxmsg = QUEUESIZE; myMq = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); if (myMq == -1) { printf("errno=%d description=%s\n", errno, strerror(errno)); } else { printf("Opened queue\n"); mq_getattr(myMq, &getattr); printf(Message Size=%ld Queue Length=%ld\n", getattr.mq_msgsize, mq_mq_maxmsg ); mq_close(myMq); mq_unlink(qname); } return 0; } }}} Compile Command: g++ -o mqueue mqueue.cpp -lrt Version-Release number of selected component (if applicable): glibc-2.3.5-10.3 How reproducible: Always Steps to Reproduce: 1. Compile the given program with a QUEUESIZE > 10 2. Review output. Actual Results: errno=22 description=Invalid argument Expected Results: Opened queue Message Size=4 Queue Length=QUEUESIZE Additional info: I have run this code on a ppc64 and i386. Kernel Version 2.6.13-1.1526_FC4 and 2.6.11.1.1369_FC4 respectively with identical results.
This doesn't have much with glibc, for mq_open glibc acts just as a wrapper around kernel syscall. Strace shows: mq_open("mq_open_name_5910", O_RDWR|O_CREAT, 0600, {mq_maxmsg=100, mq_msgsize=4}) = -1 EINVAL (Invalid argument) The kernel has several limits on how big a message queue can be to avoid users grabbing too much kernel memory. Root (well, CAP_SYS_RESOURCE holder) is allowed to create bigger queues than normal users, and some of the limits are tweakable through sysctl/proc, some are tweakable through ulimit -q. See /proc/sys/fs/mqueue/*