Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Daniel Krügler <daniel.kruegler@googlemail.com> |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Re: Is `std::ios_base::xalloc' free from data races? |
| Date | 2012-06-24 23:48 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <js6j7k$5dj$1@dont-email.me> (permalink) |
| References | <cb0a27fd-045d-4ebd-82b2-992076bf648c@oo8g2000pbc.googlegroups.com> |
Am 24.06.2012 09:03, schrieb Ai Azuma: > > Hi folks, > > I have a question about the data-race-freedom of > `std::ios_base::xalloc'. > > `std::ios_base::xalloc' has to read and modify an internal counter > object that is shared among threads. So, the implementation has to > synchronize the operations on the counter object, otherwise it may > introduce data races. > > I believe that the standard wording implicitly specifies `xalloc' is > free from data races, because the internally used shared counter > object "is not visible to users and is protected against data > races" (quoted from 17.6.5.9/7). > > However, `std::ios_base::index' is declared to be `static int' (marked > with "exposition only") in 27.5.3 (`std::ios_base' definition), and > 27.5.3.5/1 says that `xalloc' returns `index++'. Therefore, > straightforward reading of these paragraphs falls into the conclusion > that concurrent invocations of `xalloc' may introduce data races. I agree with your analysis that the current specification may introduce data races. There already exists a library issue submission request (LWG 2143 "ios_base::xalloc should be thread-safe") not yet visible in the official list. > Which is the intent of the standard, then? > > If the former interpretation (i.e., `xalloc' is free from data races) > is the intent of the standard, some editorial modifications (e.g., > declaring `std::ios_base::index' to be `static std::atomic_int' > instead of `static int' in 27.5.3) would make the wording much > clearer. > > I would like to hear from experts. Thank you in advance for your help. I think we miss normative wording that provides the necessary guarantee. We better should add explicit normative wording to that effect, IMO. HTH & Greetings from Bremen, Daniel Krügler -- [ comp.std.c++ is moderated. To submit articles, try posting with your ] [ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
Is `std::ios_base::xalloc' free from data races? Ai Azuma<ai.azuma@gmail.com> - 2012-06-24 00:03 -0700
Re: Is `std::ios_base::xalloc' free from data races? Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-06-24 23:48 -0700
Re: Is `std::ios_base::xalloc' free from data races? Ai Azuma<ai.azuma@gmail.com> - 2012-06-25 08:45 -0700
csiph-web