public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-8588] libstdc++: Fix incorrect size calculation in PMR resource (PR 94906)
@ 2020-05-12 19:41 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-05-12 19:41 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:45a6686e76bfcd48f7c72a23d0e15186f76b4bfc
commit r9-8588-g45a6686e76bfcd48f7c72a23d0e15186f76b4bfc
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue May 12 09:54:44 2020 +0100
libstdc++: Fix incorrect size calculation in PMR resource (PR 94906)
Calculating the size of a chunk being returned to the upstream allocator
was done with a 32-bit type, so it wrapped if the chunk was 4GB or
larger.
I don't know how to test this without allocating 4GB, so there's no test
in the testsuite. It has been tested manually of course.
Backport from mainline
2020-05-04 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/94906
* src/c++17/memory_resource.cc
(monotonic_buffer_resource::_Chunk::release): Use size_t for shift
operands.
Diff:
---
libstdc++-v3/ChangeLog | 10 ++++++++++
libstdc++-v3/src/c++17/memory_resource.cc | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a1d06b6fff1..57dde8c5533 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,13 @@
+2020-05-12 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2020-05-04 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/94906
+ * src/c++17/memory_resource.cc
+ (monotonic_buffer_resource::_Chunk::release): Use size_t for shift
+ operands.
+
2020-05-07 Eric Botcazou <ebotcazou@adacore.com>
* config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: Update.
diff --git a/libstdc++-v3/src/c++17/memory_resource.cc b/libstdc++-v3/src/c++17/memory_resource.cc
index e28526d1bfe..f39360cb4bf 100644
--- a/libstdc++-v3/src/c++17/memory_resource.cc
+++ b/libstdc++-v3/src/c++17/memory_resource.cc
@@ -228,8 +228,8 @@ namespace pmr
if (__ch->_M_canary != (__ch->_M_size | __ch->_M_align))
return; // buffer overflow detected!
- size_t __size = (1u << __ch->_M_size);
- size_t __align = (1u << __ch->_M_align);
+ size_t __size = (size_t)1 << __ch->_M_size;
+ size_t __align = (size_t)1 << __ch->_M_align;
void* __start = (char*)(__ch + 1) - __size;
__r->deallocate(__start, __size, __align);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-12 19:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 19:41 [gcc r9-8588] libstdc++: Fix incorrect size calculation in PMR resource (PR 94906) Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).