[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-server-cvs
Subject: [Server-cvs] engine/core/pub shmem_debug.h,1.1.2.1,1.1.2.2
From: dcollins () helixcommunity ! org
Date: 2013-08-30 22:52:45
[Download RAW message or body]
Update of /cvsroot/server/engine/core/pub
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv24325/pub
Modified Files:
Tag: SERVER_NUCLEUS
shmem_debug.h
Log Message:
Synopsis
========
Fixes RPDS memory corruption, possibly related to RPD-1975
Branches: Jupiter / SERVER_NUCLEUS
Reviewer: Jamie
Description
===========
Memory allocations and deletions from threads not managed by the server
core (such as httpfsysshim.dll worker threads) were updating the
bytes_in_use_counters[] array using an index of -1, resulting in
updates to the wrong location in memory.
While I detected this when debugging RPD-1975, it may or may not be
related. I didn't actually trap errors or crashes directly caused by
this, I noticed it while walking through code with the debugger.
The memory in use counter is distributed across multiple integers so
each thread can update a counter without colliding with other threads.
For non-server-core threads, we now update the last item in the counter
array, MAX_THREADS-1.
I also noticed an old bug in that the bytes_in_use_counters array was
not being initialized correctly, which could lead to an unreliable
memory usage counter. This is fixed as well in this diff.
Files Affected
==============
server/engine/core/memsys.cpp
server/engine/core/pub/memsys.h
server/engine/core/shmem_debug.cpp
server/engine/core/pub/shmem_debug.h
Testing Performed
=================
Unit Tests:
- None
Integration Tests:
- Performed cloud uploads using the Virtual Folder.
- Tested with debug memory and the default system-based memory.
Leak Tests:
- None
Performance Tests:
- None
Platforms Tested: Windows 7 / x86 (Debug & Release)
Builds Verified: VC10 / x86 / Debug & Release
QA Hints
========
N/A
Index: shmem_debug.h
===================================================================
RCS file: /cvsroot/server/engine/core/pub/shmem_debug.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- shmem_debug.h 24 Jul 2012 01:25:23 -0000 1.1.2.1
+++ shmem_debug.h 30 Aug 2013 22:52:27 -0000 1.1.2.2
@@ -247,6 +247,27 @@
return g_pSizeToBucket[size >> 4];
}
+inline void
+update_bytes_in_use_counter(HX_SIZE_T* pCounters, int nDelta)
+{
+ int nProcnumForCounter = Process::get_procnum();
+ if (nProcnumForCounter >= 0)
+ {
+ // counter for server-core-based threads
+ pCounters[nProcnumForCounter] += nDelta;
+ }
+ else
+ {
+ // Unmanaged threads don't have a procnum. Since there may be multiple
+ // of these threads, we use an atomic operator.
+ nProcnumForCounter = MAX_THREADS-1;
+#if defined(_WIN64) || defined(_LONG_IS_64)
+ HXAtomicAddINT64((INT64*)&(pCounters[nProcnumForCounter]), nDelta);
+#else
+ HXAtomicAddINT32((INT32*)&(pCounters[nProcnumForCounter]), nDelta);
+#endif
+ }
+}
class _InUsePage;
@@ -452,6 +473,7 @@
{
nSum += self->bytes_in_use_counters[i];
}
+ nSum += self->bytes_in_use_counters[MAX_THREADS-1];
*self->bytes_in_use = nSum;
return nSum;
}
_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic