Bug 170874 - Unable to create posix message queue of length > 10
Unable to create posix message queue of length > 10
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
powerpc Linux
medium Severity medium
: ---
: ---
Assigned To: Kernel Maintainer List
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-10-14 16:45 EDT by Daniel Shay
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-10-15 08:58:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Daniel Shay 2005-10-14 16:45:55 EDT
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 );
  return 0;


Compile Command: g++ -o mqueue mqueue.cpp -lrt

Version-Release number of selected component (if applicable):

How reproducible:

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 respectively with identical results.
Comment 1 Jakub Jelinek 2005-10-15 08:58:42 EDT
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/*

Note You need to log in before you can comment on or make changes to this bug.