Bug(?) of libstdc++ (COW is still used)

Takashi Yano takashi.yano@nifty.ne.jp
Sat Aug 15 02:36:13 GMT 2026


On Sat, 15 Aug 2026 11:33:00 +0900
Takashi Yano wrote:
> Hi,
> 
> I noticed that the libstdc++ on Cygwin still uses COW (copy-on-write),
> which is inhibited since C++11.
> 
> The following code:
> 
> #include <string>
> #include <cassert>
> #include <cstdio>
> 
> int main()
> {
> 	std::string a("AAAA");
> 	std::string b;
> 	b = a;
>     
> 	printf("%d\n", _GLIBCXX_USE_CXX11_ABI);
> 	printf("%p, %p: %s\n", a.c_str(), b.c_str(), b.c_str());
> 	b[0] = 'B';
> 	printf("%p, %p: %s\n", a.c_str(), b.c_str(), b.c_str());
> 
>     return 0;
> }
> 
> outputs
> 
> 0
> 0xa00000648, 0xa00000648: AAAA
> 0xa00000648, 0xa00000568: BAAA
> 
> $ cygcheck -c libstdc++6
> Cygwin Package Information
> Package              Version    Status
> libstdc++6           14.4.0-1       OK
> 
> Due to this, glslc in shaderc package sometimes crashes in libglslang.a
> because of Use-After-Free problem.

https://github.com/KhronosGroup/glslang/issues/4381

> Is there any reason that libstdc++ on Cygwin still uses COW
> (_GLIBCXX_USE_CXX11_ABI = 0 setting), even though it is inhibited
> since C++11?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin mailing list