View Issue Details

IDProjectCategoryView StatusLast Update
00012371003.1(2016/18)/Issue7+TC2System Interfacespublic2024-06-11 09:08
Reporterkre Assigned To 
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted As Marked 
NameRobert Elz
Organization
User Reference
Sectionshmat
Page Number1940
Line Number62494
Interp Status---
Final Accepted Text0001237:0004435
Summary0001237: shmat() specifies use of an undefined operation
DescriptionThe parameter shmaddr to the shmat() function is of type void *
and the standard specifies:


  • If shmaddr is not a null pointer and (shmflg &SHM_RND) is non-zero, the segment
    is attached at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)). The
     character '%' is the C-language remainder operator.


Arithmetic on (void *) pointers is undefined,
so no address can be calculated as specified.
Desired Action


Three possible solutions appear reasonable.



Pick one:



  1. In line 62494 in page 1940 change the wording
    from:

    at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)).

    to:

    at the address given by (void *)((uintptr_t)shmaddr -((uintptr_t)shmaddr %SHMLBA
    )).

  2. In line 62494 in page 1940 change the wording
    from:

    at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)).

    to:

    at the address given by (void *)((char *)shmaddr -((uintptr_t)shmaddr %SHMLBA)).

  3. Delete all of pages 1940 to 1947 (inclusive).


Tagstc3-2008

Relationships

related to 0001238 Closed shmat() used the word "it" with an ambiguous antecedent 
related to 0001239 Closed shmat() specifies non-portable return value 
related to 0001240 Closed shmctl(IPC_RMID) relationship with attached shared memory segments is not specified 

Activities

geoffclare

2019-03-18 09:57

manager   bugnote:0004328

In XPG3 shmaddr had type char *, so adding a (char *) cast as in option 2 is the change that should have been made when shmaddr was changed to void * in XPG4.

The additional (void *) cast is unnecessary, as there is no problem with "the address given by" being followed by an expression of type char *.

kre

2019-03-18 10:39

reporter   bugnote:0004329

That(0001237:0004328) is fine.

geoffclare

2019-06-20 11:01

manager   bugnote:0004435

Last edited: 2019-06-20 15:37

Suggested change:

In line 62494 in page 1940 change:
at the address given by (shmaddr -((uintptr_t)shmaddr %SHMLBA)).
to:
at the address given by ((char *)shmaddr - ((uintptr_t)shmaddr % SHMLBA)).


Issue History

Date Modified Username Field Change
2019-03-16 09:45 kre New Issue
2019-03-16 09:45 kre Name => Robert Elz
2019-03-16 09:45 kre Section => shmat
2019-03-16 09:45 kre Page Number => 1940
2019-03-16 09:45 kre Line Number => 62494
2019-03-18 09:57 geoffclare Note Added: 0004328
2019-03-18 10:39 kre Note Added: 0004329
2019-06-20 11:01 geoffclare Note Added: 0004435
2019-06-20 11:02 geoffclare Note Edited: 0004435
2019-06-20 15:37 geoffclare Note Edited: 0004435
2019-06-20 15:38 geoffclare Interp Status => ---
2019-06-20 15:38 geoffclare Final Accepted Text => 0001237:0004435
2019-06-20 15:38 geoffclare Status New => Resolved
2019-06-20 15:38 geoffclare Resolution Open => Accepted As Marked
2019-06-20 15:38 geoffclare Tag Attached: tc3-2008
2019-06-24 15:37 eblake Relationship added related to 0001240
2019-06-24 15:38 eblake Relationship added related to 0001238
2019-06-24 15:38 eblake Relationship added related to 0001239
2019-11-14 14:33 geoffclare Status Resolved => Applied
2024-06-11 09:08 agadmin Status Applied => Closed