microsoft / microsoft/STL

<algorithm>: debug checks for predicates are observable

Open
#1,006 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

Describe the bug
Debug version std::min_element assumes that the range is not modified while working on it.

It triggers the following check:
https://github.com/microsoft/STL/blob/5be7d49c243979231dff35919d3a3d813d75d714/stl/inc/xutility#L1589-L1598

This assertion is triggered when std::min_element is used on array of std::atomic values that are incremented independently by concurrent threads.

DevCom-222276 reporter asks:

Are there any limitations in the standard about std::min_elements() that I should know?

Additional context

Also tracked by DevCom-222276 and Microsoft-internal VSO-592348 / AB#592348.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the debug check in stl/inc/xutility around lines 1589-1598 and the skipped libcxx entries in tests/libcxx/expected_results.txt around lines 586-589. Reproduce the std::min_element scenario using concurrently incremented std::atomic values, then establish the expected handling of the observable predicate checks and update the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.