Bug 14007 – shmctl with IPC_STAT returns wrong number of attachments. shmid_ds is defined wrong.

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-01-19T04:13:00Z
Last change time
2015-02-18T03:38:47Z
Keywords
pull
Assigned to
nobody
Creator
10l94s+31wgxrstmw2bk

Attachments

IDFilenameSummaryContent-TypeSize
1464main-works.dD codes with solutionapplication/x-dsrc2189
1465main.cC codestext/x-csrc723
1466main.dSame as C code, but buggyapplication/x-dsrc777
1467makefileMake file to build all codestext/plain128
1468shm.dThis is the fixed shm.d fileapplication/x-dsrc3811

Comments

Comment #0 by 10l94s+31wgxrstmw2bk — 2015-01-19T04:13:00Z
Created attachment 1464 D codes with solution I have written a simple code to create a shared memory segment (shmget). Then attached it (shmat), and got the statistics information for that shared memory. According to documentation of shmat, number of attachments (shm_nattch) should be 1. I wrote same code in both C and D. C returns 1, D return 0. C's shmid_ds is defined in /usr/include/bits/shm.h D's shmid_ds is defined in core.sys.posix.sys.shm C's definition contains conditionals for 64 bit systems. D has definition for Linux only, no Posix. And its definition is done for 32-bit systems only. I then defined the shmid_ds myself with conditional by using "version". Finally it is solved. I attached the working solution. "dmd main-works.d" will do it. I am not familiar with merge requests. So I am putting it here.
Comment #1 by 10l94s+31wgxrstmw2bk — 2015-01-19T04:13:36Z
Created attachment 1465 C codes This code works as supposed to be
Comment #2 by 10l94s+31wgxrstmw2bk — 2015-01-19T04:14:43Z
Created attachment 1466 Same as C code, but buggy
Comment #3 by 10l94s+31wgxrstmw2bk — 2015-01-19T04:16:54Z
Created attachment 1467 Make file to build all codes
Comment #4 by 10l94s+31wgxrstmw2bk — 2015-01-19T05:33:59Z
Created attachment 1468 This is the fixed shm.d file This is the fixed shm.d file. Can someone put a pull request on Github for this. By using this file, the issue is solved.
Comment #5 by ag0aep6g — 2015-01-19T14:53:07Z
Comment #6 by github-bugzilla — 2015-01-19T17:19:54Z
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/58504ecda814127cadfe7cb395d1e3274802caf4 version away __unused1/2/3 for X86_64 Fixes Issue 14007 - shmctl with IPC_STAT returns wrong number of attachments. shmid_ds is defined wrong. Fix originally by tcak via Bugzilla.
Comment #7 by github-bugzilla — 2015-02-18T03:38:47Z