1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Disable single thread optimization for open_memstream

Single thread optimization is valid if at thread creation time the
optimization can be disabled.  This is in principle true for all
stream objects that user code can access (and thus needs locking),
using the same internal list as fflush(0) uses.  However in glibc
open_memstream is not on that list (BZ 21735) so the optimization
has to be disabled.

	* libio/memstream.c (__open_memstream): Set _IO_FLAGS2_NEED_LOCK.
	* libio/wmemstream.c (open_wmemstream): Likewise.
	* nptl/tst-memstream.c: New.
This commit is contained in:
Szabolcs Nagy
2017-07-12 10:53:13 +01:00
parent 8bd8c052e7
commit de895ddcd7
5 changed files with 115 additions and 1 deletions

View File

@ -96,6 +96,9 @@ __open_memstream (char **bufloc, _IO_size_t *sizeloc)
new_f->fp.bufloc = bufloc;
new_f->fp.sizeloc = sizeloc;
/* Disable single thread optimization. BZ 21735. */
new_f->fp._sf._sbf._f._flags2 |= _IO_FLAGS2_NEED_LOCK;
return (_IO_FILE *) &new_f->fp._sf._sbf;
}
libc_hidden_def (__open_memstream)