Anonymous | Login | 2024-09-07 15:15 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0000188 | [1003.1(2008)/Issue 7] System Interfaces | Objection | Enhancement Request | 2009-11-26 10:50 | 2024-06-11 08:53 | ||
Reporter | geoffclare | View Status | public | ||||
Assigned To | ajosey | ||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Closed | ||||||
Name | Geoff Clare | ||||||
Organization | The Open Group | ||||||
User Reference | |||||||
Section | getenv | ||||||
Page Number | 1008 | ||||||
Line Number | 33858 | ||||||
Interp Status | Approved | ||||||
Final Accepted Text | Note: 0000325 | ||||||
Summary | 0000188: thread-safe getenv() | ||||||
Description |
The standard says that getenv() need not be thread-safe. Since there is no getenv_r() function, this makes obtaining environment variable values somewhat inconvenient in multi-threaded conforming applications. I imagine there are a large number of applications that don't bother to be careful with getenv() and just assume it is thread-safe. It probably is thread-safe on most, if not all, implementations that support POSIX threads. The reason getenv() is not required to be thread-safe is stated in the rationale: "The getenv() function is inherently not thread-safe because it returns [sic] a value pointing to static data." (I added "[sic]" because it should say "may return" not "returns".) I think it likely that the only POSIX implementations where getenv() copies the value to an internal buffer are UNIX implementations where the UNIX APIs have been added to an O/S that was not originally UNIX. It's possible none of these implement POSIX threads, or if they do then they may have made getenv() thread-safe by using per-thread internal buffers instead of a single buffer. Therefore I think the standard should require getenv() to be thread-safe. If there are any implementations which copy to an internal buffer, and either have POSIX threads or want to add POSIX threads in the future, they can conform simply by using per-thread internal buffers. |
||||||
Desired Action |
At line 33853 change: The string pointed to may be overwritten by a subsequent call to getenv(), [CX]setenv(), unsetenv(),[/CX] [XSI]or putenv()[/XSI] but shall not be overwritten by a call to any other function in this volume of POSIX.1-2008. to: The string pointed to may be overwritten by a subsequent call to getenv(), [CX]setenv(), unsetenv(),[/CX] [XSI]or putenv()[/XSI] from the same thread but shall not be overwritten by a call to any of these functions from another thread or by a call to any other function in this volume of POSIX.1-2008 from any thread. At line 33858 delete: The getenv() function need not be thread-safe. At line 33878 change: The getenv() function is inherently not thread-safe because it returns a value pointing to static data. to: Some earlier versions of this standard did not require getenv() to be thread-safe because it may return a value pointing to static data. However, implementations of getenv() that do this can be made thread-safe by using per-thread internal buffers instead of a single buffer. Therefore getenv() is now required to be thread-safe (except when another thread is modifying the environment). At line 33908 delete: A future version may add one or more functions to access and modify the environment in a thread-safe manner. At page 507 line 17494 section 2.9.1 delete getenv() from the list of functions that need not be thread-safe. At page 508 line 17518 change: any function dependent on any environment variable is not thread-safe if another thread is modifying the environment to: the getenv() function and any function dependent on any environment variable are not thread-safe if another thread is modifying the environment |
||||||
Tags | issue8 | ||||||
Attached Files | |||||||
|
Relationships | |||||||
|
Issue History | |||
Date Modified | Username | Field | Change |
2009-11-26 10:50 | geoffclare | New Issue | |
2009-11-26 10:50 | geoffclare | Status | New => Under Review |
2009-11-26 10:50 | geoffclare | Assigned To | => ajosey |
2009-11-26 10:50 | geoffclare | Name | => Geoff Clare |
2009-11-26 10:50 | geoffclare | Organization | => The Open Group |
2009-11-26 10:50 | geoffclare | Section | => getenv |
2009-11-26 10:50 | geoffclare | Page Number | => 1008 |
2009-11-26 10:50 | geoffclare | Line Number | => 33858 |
2009-11-26 10:50 | geoffclare | Interp Status | => --- |
2009-11-26 16:25 | drepper | Note Added: 0000309 | |
2009-12-01 10:11 | geoffclare | Note Added: 0000311 | |
2009-12-02 19:04 | msbrown | Note Added: 0000313 | |
2009-12-10 16:35 | msbrown | Interp Status | --- => Pending |
2009-12-10 16:35 | msbrown | Note Added: 0000325 | |
2009-12-10 16:35 | msbrown | Type | Error => Enhancement Request |
2009-12-10 16:35 | msbrown | Status | Under Review => Interpretation Required |
2009-12-10 16:35 | msbrown | Resolution | Open => Accepted As Marked |
2009-12-10 16:35 | msbrown | Description Updated | |
2009-12-10 16:35 | msbrown | Final Accepted Text | => Note: 0000325 |
2010-02-12 06:38 | ajosey | Interp Status | Pending => Proposed |
2010-03-25 15:15 | geoffclare | Note Edited: 0000325 | |
2010-03-25 15:16 | geoffclare | Interp Status | Proposed => Approved |
2010-09-24 14:42 | Don Cragun | Tag Attached: issue8 | |
2019-12-20 12:00 | geoffclare | Status | Interpretation Required => Applied |
2020-08-26 09:19 | geoffclare | Relationship added | related to 0001394 |
2024-06-11 08:53 | agadmin | Status | Applied => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |