This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.10-374-g22bc523
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 29 Oct 2009 18:25:35 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.10-374-g22bc523
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 22bc5239e1c7d97b0642af6c135af994586f8e82 (commit)
from d94760f944cebf05b239dd0b65c3b40a5577013b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=22bc5239e1c7d97b0642af6c135af994586f8e82
commit 22bc5239e1c7d97b0642af6c135af994586f8e82
Author: Andreas Schwab <schwab@redhat.com>
Date: Thu Oct 29 11:25:20 2009 -0700
Fix wrap-around in memusage.
diff --git a/ChangeLog b/ChangeLog
index 25bb325..99088df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-29 Andreas Schwab <schwab@redhat.com>
+
+ * malloc/memusage.c (update_data): Fix index wraparound handling
+ so that buffer_cnt is actually reset.
+
2009-10-29 Ulrich Drepper <drepper@redhat.com>
[BZ #10784]
diff --git a/malloc/memusage.c b/malloc/memusage.c
index fcd58dc..382261c 100644
--- a/malloc/memusage.c
+++ b/malloc/memusage.c
@@ -163,15 +163,16 @@ update_data (struct header *result, size_t len, size_t old_len)
if (fd != -1)
{
uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1);
- if (idx >= 2 * buffer_size)
+ if (idx + 1 >= 2 * buffer_size)
{
/* We try to reset the counter to the correct range. If
this fails because of another thread increasing the
counter it does not matter since that thread will take
care of the correction. */
- uatomic32_t reset = idx % (2 * buffer_size);
- catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx);
- idx = reset;
+ uatomic32_t reset = (idx + 1) % (2 * buffer_size);
+ catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1);
+ if (idx >= 2 * buffer_size)
+ idx = reset - 1;
}
assert (idx < 2 * DEFAULT_BUFFER_SIZE);
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 5 +++++
malloc/memusage.c | 9 +++++----
2 files changed, 10 insertions(+), 4 deletions(-)
hooks/post-receive
--
GNU C Library master sources