Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<forward_list>, <string>, <vector>: Debug mode STL causes terminate() to be called under low memory #1035

Open
AlexGuteniev opened this issue Jul 12, 2020 · 3 comments
Labels
bug Something isn't working vNext Breaks binary compatibility

Comments

@AlexGuteniev
Copy link
Contributor

AlexGuteniev commented Jul 12, 2020

Describe the bug
std::basic_string, std::vector default constructor is noexcept, which corresponds to the standard, but it allocates during construction, and thus may throw

Command-line test case
9525-ms-bug-repros.zip

STL version

Microsoft Visual Studio Professional 2019 Preview
Version 16.7.0 Preview 3.1

Additional context
Also tracked by DevCom-77779 and VSO-466800 / AB#466800

Similar issue is also tracked by Also tracked by DevCom-246249 and VSO-470756 / AB#470756

@StephanTLavavej StephanTLavavej added bug Something isn't working vNext Breaks binary compatibility labels Jul 21, 2020
@StephanTLavavej
Copy link
Member

Yep - I have a fix stranded in our vNext branch in TFS (that avoids allocating the "proxy" object; I implemented the fix for all containers except deque and vector<bool> before running out of time, but it can be finished).

@frederick-vs-ja
Copy link
Contributor

Currently constexpr std::vector<T> v{}; compiles in release mode (_ITERATOR_DEBUG_LEVEL == 0) but not in debug mode, which is surprisingly inconsitent. Such inconsistency can't be fixed as long as the proxy object is dynamically allocated.

In vNext, it seems that the proxy becomes a subobject of the container object. However, if the proxy is still self-referential, there will still be inconsistency:

  • in release mode, constexpr std::vector<T> v{}; compiles wherever the variable is, however,
  • in debug mode, it only compiles if v has static storage duration!

This inconsistency is already present for libstdc++'s basic_string (can't be fixed without ABI break, too). Will vNext get rid of the self-reference problem?

@StephanTLavavej
Copy link
Member

The iterator debugging overhaul that I wrote for vNext (in our stranded Team Foundation Version Control branch) entirely eliminated the proxy object, instead taking a lock whenever it needs to update all children. (I didn't get around to overhauling deque and vector<bool> but it should be possible to update them too).

@StephanTLavavej StephanTLavavej changed the title <string>, <vector> Debug version of STL is not exception safe and causes terminate() to be called under low memory <forward_list>, <string>, <vector>: Debug mode STL causes terminate() to be called under low memory Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vNext Breaks binary compatibility
Projects
None yet
Development

No branches or pull requests

3 participants