aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2017-07-12 10:53:13 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2017-07-14 16:09:56 +0100
commitde895ddcd7fc45caeeeb0ae312311b8bd31d82c5 (patch)
tree7c4d633905c2e5b2fb466ff6ccf32afe735893b2 /libio
parent8bd8c052e765d626fae1424e2739d009a185a6ba (diff)
downloadglibc-de895ddcd7fc45caeeeb0ae312311b8bd31d82c5.zip
glibc-de895ddcd7fc45caeeeb0ae312311b8bd31d82c5.tar.gz
glibc-de895ddcd7fc45caeeeb0ae312311b8bd31d82c5.tar.bz2
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.
Diffstat (limited to 'libio')
-rw-r--r--libio/memstream.c3
-rw-r--r--libio/wmemstream.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/libio/memstream.c b/libio/memstream.c
index f83d4a5..e391efd 100644
--- a/libio/memstream.c
+++ b/libio/memstream.c
@@ -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)
diff --git a/libio/wmemstream.c b/libio/wmemstream.c
index 5bc77f5..103a760 100644
--- a/libio/wmemstream.c
+++ b/libio/wmemstream.c
@@ -98,6 +98,9 @@ open_wmemstream (wchar_t **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;
}