diff -r e7d2d738d3c2 -r 2f92ad2dc5db kernel/eka/euser/us_test.cpp --- a/kernel/eka/euser/us_test.cpp Mon Mar 15 12:45:50 2010 +0200 +++ b/kernel/eka/euser/us_test.cpp Wed Mar 31 23:38:45 2010 +0300 @@ -549,6 +549,14 @@ User::AfterHighRes(period); } User::WaitForRequest(s); + + // There is a potential race condition, if the calling thread runs on a different CPU + // than the Supervisor thread, which can result in this thread being signaled + // before the RHandleBase gets fully closed (see DChangeNotifier::Complete()). + // For that reason, wait until Supervisor thread gets to idle, which is the indication + // that Complete() function has returned (DThread::Close() was called releasing memory), + // in the case that Kernel heap was checked just after current method returns. + UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)timeout, NULL); return r; }