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

<syncstream>: std::osyncstream memory leak #2760

Closed
fsb4000 opened this issue Jun 4, 2022 · 0 comments · Fixed by #2763
Closed

<syncstream>: std::osyncstream memory leak #2760

fsb4000 opened this issue Jun 4, 2022 · 0 comments · Fixed by #2763
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@fsb4000
Copy link
Contributor

fsb4000 commented Jun 4, 2022

If we change “Hello, this line is long, LEAK incoming” to be under 32 characters long, then there are no leaks detected.

Command-line test case

$ type main.cpp
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#include <iostream>
#include <syncstream>

int main() {
    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

    std::osyncstream bout(std::cout);
    bout << "Hello, this line is long, LEAK incoming" << '\n';
    bout.emit();
}


$ cl /std:c++20 /permissive- /EHsc /MDd /nologo main.cpp
main.cpp

$ main.exe
Hello, this line is long, LEAK incoming
Detected memory leaks!
Dumping objects ->
{205} normal block at 0x000001B70E3A0360, 32 bytes long.
 Data: <Hello, this line> 48 65 6C 6C 6F 2C 20 74 68 69 73 20 6C 69 6E 65
Object dump complete.

Expected behavior
No memory leak.

STL version

Microsoft Visual Studio Community 2022 Preview
Version 17.3.0 Preview 1.1

Additional context
This was originally reported as Devcom-10061535/VSO-1551615/AB#1551615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants