Skip to content

<iterator>: istreambuf_iterator violates [res.on.data.races] #5066

Open
@CaseyCarter

Description

@CaseyCarter

The existence of mutable members:

STL/stl/inc/iterator

Lines 480 to 482 in a1bc126

mutable streambuf_type* _Strbuf; // the wrapped stream buffer
mutable bool _Got; // true if _Val is valid
mutable _Elem _Val; // next element to deliver

modified by const member functions without any kind of mutual exclusion:

STL/stl/inc/iterator

Lines 468 to 477 in a1bc126

_Elem _Peek() const { // peek at next input element
int_type _Meta;
if (!_Strbuf || traits_type::eq_int_type(traits_type::eof(), _Meta = _Strbuf->sgetc())) {
_Strbuf = nullptr;
} else {
_Val = traits_type::to_char_type(_Meta);
}
_Got = true;
return _Val;

is a veritable recipe for data races. We've traditionally considered fixing this to require ABI breakage, but I wouldn't be surprised if there were a way to replace some of the data members with atomics in such a way that we could provide a conforming implementation to new code that doesn't break down completely when linked to old code.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

This was VSO-454475 / AB#454475.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvNextBreaks binary compatibility

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions