Bug 246509
Summary: | shmctl returns EIDRM when it should say EINVAL | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 4 | Reporter: | Tom Lane <tgl> | ||||
Component: | kernel | Assignee: | Anton Arapov <anton> | ||||
Status: | CLOSED WONTFIX | QA Contact: | Martin Jenner <mjenner> | ||||
Severity: | low | Docs Contact: | |||||
Priority: | low | ||||||
Version: | 4.0 | CC: | hhorak, jbaron, nobody | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2007-08-20 15:56:01 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Tom Lane
2007-07-02 18:55:47 UTC
Created attachment 158364 [details]
Test program to exercise the bug
Its actually inconsistant: ------------------------------------------------------------------------ [lwoodman@dhcp83-56 Desktop]$ ./shmctl-bug id1 = 62357524 / 0x3b78014 id2 = 62390295 / 0x3b80017 id3 = 62423060 / 0x3b88014 shmctl(62357524 / 0x3b78014, IPC_STAT): ERROR: Identifier removed shmctl(62390295 / 0x3b80017, IPC_STAT): ERROR: Invalid argument ------------------------------------------------------------------------ This is what the SHMCTL(2) manpage says for IPC_STAT: EIDRM is returned if shmid points to a removed identifier. The attached program does: 1.) shmid1 = shmget(0x12345678, 1024 * 1024, IPC_CREAT | IPC_EXCL | 0600); 2.) shmid2 = shmget(0x12345678, 1024 * 1024, IPC_CREAT | IPC_EXCL | 0600); 3.) shmctl(shmid1, IPC_RMID, NULL); 4.) shmctl(shmid2, IPC_RMID, NULL); 5.) shmctl(shmid1, IPC_STAT, &buf); 6.) shmctl(shmid2, IPC_STAT, &buf); The shmctl(shmid1, IPC_STAT, &buf) returns EIDRM while the shmctl(shmid2, IPC_STAT, &buf) returns EINVAL. I'd say it should be returning EIDRM for both since the id was removed. Larry Woodman Actually, looking at this agian, I thing the program is wrong. You should be passing SHM_STAT and not IPC_STAT to shmctl. [lwoodman@dhcp83-56 Desktop]$ ./shmctl-bug id1 = 62750740 / 0x3bd8014 id2 = 62783511 / 0x3be0017 id3 = 62816276 / 0x3be8014 shmctl(62750740 / 0x3bd8014, IPC_STAT): ERROR: Invalid argument shmctl(62783511 / 0x3be0017, IPC_STAT): ERROR: Invalid argument [lwoodman@dhcp83-56 Desktop]$ diff shmctl-bug.c.orig shmctl-bug.c 69c69 < if (shmctl(shmid1, IPC_STAT, &buf) < 0) --- > if (shmctl(shmid1, SHM_STAT, &buf) < 0) 75c75 < if (shmctl(shmid2, IPC_STAT, &buf) < 0) --- > if (shmctl(shmid2, SHM_STAT, &buf) < 0) IPC_STAT is defined by the Single Unix Spec, SHM_STAT is not. Telling me to use an unportable option to fix a lack of portable behavior is not an acceptable answer. http://www.opengroup.org/onlinepubs/007908799/xsh/shmctl.html Now that I look at it, the SUS mentions EINVAL but not EIDRM as a possible failure for shmctl(), so the current kernel behavior is not merely self-inconsistent but a flat violation of the spec. So, we are back to my questions... I'm fully support Tom. IMHO we should follow specification. And in this case enough to change the behavior of the shmctl/msgctl/semctl functions. But I don't know how this change reflects on the kernel in a whole... this is one of the questions to gurus! The second, why this problem exists for a long time and never was discussed on lkml?... I can't believe that no one had experience with this until now! http://post-office.corp.redhat.com/archives/rhkernel-list/2007-July/msg00784.html Removing the EIDRM would break userspace applications currently depending on it. The only way to write portable, between Linux and other *NIX clones, application is to test for the error code by (EINVAL || EIDRM). |