Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000386 [1003.1(2008)/Issue 7] System Interfaces Objection Enhancement Request 2011-02-22 23:58 2013-04-16 13:06
Reporter eblake View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Eric Blake
Organization Red Hat
User Reference ebb.environ
Section 2.2.2 The Name Space
Page Number 469
Line Number 15936
Interp Status ---
Final Accepted Text See Note: 0000721
Summary 0000386: environ should be declared in <unistd.h>
Description The standard appears to be ambiguous - XBD <unistd.h> does not list environ,
but XSH exec (line 25687) implies that #include <unistd.h> will provide
the declaration, rather than documenting the burden on the application to
declare it. Meanwhile, many implementations already declare environ in
<unistd.h> (possibly when requesting extensions to the standard), and it
seems awkward to require special-case treatment for environ. This proposal
changes things to remove the special casing.

If my Desired Action is not taken as-is, then we should at least update the
wording in XSH exec to make it explicit that the user must declare the
variable themselves (in fact, such wording might be useful in TC1, while
delaying this proposal to issue 8).
Desired Action At line 15126 [XBD <unistd.h>], insert:

extern char **environ;

At line 15936 [XSH 2.2.2 The Name Space], delete ", except environ,".

At line 26007 [XSH exec APPLICATION USAGE], add a paragraph:

Older versions of this standard required that applications provide the
declaration:

extern char **environ;

before using environ, since no standard header was required to
provide it. Code may safely keep such a declaration, even though this
version of the standard now requires <unistd.h> to declare environ.
Tags tc1-2008
Attached Files

- Relationships
related to 0000167Closedajosey 1003.1(2008)/Issue 7 getenv() and modifying environ directly 
has duplicate 0001246Closed 1003.1(2016/18)/Issue7+TC2 environ missing. 

-  Notes
(0000677)
geoffclare (manager)
2011-02-23 11:49

There is also the environ pointer page to consider (page 763), which has no mention of <unistd.h> in the synopsis.
(0000678)
Don Cragun (manager)
2011-02-23 19:47

There are several warnings in the standard that using environ in a
multithreaded application causes undefined behavior as well as
statements that environ is not defined in any header (and the reasons
why this is the intended behavior of the standard). See XSH 2.2.2
(The Name Space) P469, L15936; 2.9.1 (Thread Safety) P508, L17516;
XSH exec DESCRIPTION P772, L25713; XSH exec APPLICATION USAGE P779,
L25989; XSH exec RATIONALE P781, L26059-26060; XSH getenv() DESCRIPTION
P1008, L33856; XSH getenv() RATIONALE P1008-1009, L33880-33897; XSH
setenv() DESCRIPTION P99347-99348; XSH unsetenv() DESCRIPTION P2161,
L68256-68257; XRAT A.8.1 (Environment Variable Definition) P3467,
L116537-116540 for examples of why environ should not be defined
in any header and the user should be required to define environ if
it is going to be used instead of the preferred getenv(), setenv(),
and putenv() functions.

I believe this change should be rejected.
(0000679)
eblake (manager)
2011-02-23 20:26

See 0000167 - TC1 is changing things to state that modification of
the array pointed to by environ, or of an entry in the array pointed to
by environ, is not multi-thread safe, but that reading environ in order
to initialize a const **char pointer to walk through and read the array,
as well as assignment to environ, _is_ safe, even in a multi-threaded
application. Therefore, your fears about accessing environ are unfounded,
and there no longer exists a reason to hide environ from being declared.
(0000721)
nick (manager)
2011-03-24 16:20

At line 25708, change "In addition, the following variable:" to

"In addition, the following variable, which must be declared by the user if it is to be used directly:"

- Issue History
Date Modified Username Field Change
2011-02-22 23:58 eblake New Issue
2011-02-22 23:58 eblake Status New => Under Review
2011-02-22 23:58 eblake Assigned To => ajosey
2011-02-22 23:58 eblake Name => Eric Blake
2011-02-22 23:58 eblake Organization => Red Hat
2011-02-22 23:58 eblake User Reference => ebb.environ
2011-02-22 23:58 eblake Section => 2.2.2 The Name Space
2011-02-22 23:58 eblake Page Number => 469
2011-02-22 23:58 eblake Line Number => 15936
2011-02-22 23:58 eblake Interp Status => ---
2011-02-23 11:49 geoffclare Note Added: 0000677
2011-02-23 19:47 Don Cragun Note Added: 0000678
2011-02-23 20:25 eblake Relationship added related to 0000167
2011-02-23 20:26 eblake Note Added: 0000679
2011-03-24 16:20 nick Note Added: 0000721
2011-03-24 16:20 nick Status Under Review => Resolved
2011-03-24 16:20 nick Resolution Open => Accepted As Marked
2011-03-24 16:21 nick Final Accepted Text => See Note: 0000721
2011-03-24 16:21 nick Tag Attached: tc1-2008
2013-04-16 13:06 ajosey Status Resolved => Closed
2019-04-16 07:38 geoffclare Relationship added has duplicate 0001246


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker