Mark Russinovich’s technical blog covering topics such as Windows troubleshooting, technologies and security.
Microsoft Customer Support Services (CSS) is one of the biggest customers of the Sysinternals tools and they often send me interesting cases they’ve solved with them. This particular case is especially interesting because it affected a large number of users and the troubleshooting process made use of one of Process Monitor’s lesser-known features. The case opened when a customer contacted Microsoft support reporting that several of their users would occasionally get this error message when loggging on to their systems:
This caused Windows to create a temporary profile for the user’s logon session. A user profile consists of a directory, %UserProfile%, into which applications save user-specific configuration and data files, as well as a registry hive file stored in that directory, %UserProfile%\Ntuser.dat, that the Winlogon process loads when the user logs in. Applications store user settings in the registry hive by calling registry functions that refer to the HKEY_CURRENT_USER (HKCU) root key. The user’s loss of access to their profile made the problem critical, because whenever that happened, the user would apparently lose all their settings and access to files stored in their profile directory. In most cases, users contacted the company’s support desk, which would ask the user to try rebooting and logging in until the problem resolved itself.
As with all cases, Microsoft support began by asking about the system configuration, inventory of installed software, and about any recent changes the company had made to their systems. In this case, the fact that stood out was that all the systems on which the problem had occurred had recently been upgraded to a new version of Citrix Corporation's ICA client, a remote desktop application. Microsoft contacted Citrix support to see if they knew of any issues with the new client. They didn’t, but said they would investigate.
Unsure whether the ICA client upgrade was responsible for the profile problem, Microsoft support instructed the customer to enable profile logging, which you can do by configuring a registry key as per this Knowledge Base article: How to enable user environment debug logging in retail builds of Windows. The customer pushed a script out to their systems to make the required registry changes and shortly after got another call from a user with the profile problem. They grabbed a copy of the profile log off the system from %SystemRoot%\Debug\UserMode\Userenv.log and sent it into Microsoft. The log was inconclusive, but did provide an important clue: it indicated that the user’s profile had failed to load because of error 32, which is ERROR_SHARING_VIOLATION:
When a process opens a file, it specifies what kinds of sharing it allows for the file. If it is writing to the file it may allow other processes to read from the file, for example, but not to also write to the file. The sharing violation in the log file meant that another process had opened the user’s registry hive in a way that was incompatible with the way that the logon process wanted to open the file.
In the meantime, more customers around the world began contacting Microsoft and Citrix with the same issue, all had also deployed the new ICA client. Citrix support then reported that they suspected that the sharing violation might be caused by one of the ICA client’s processes, Ssonvr.exe. During installation, the ICA client registers a Network Provider DLL (Pnsson.dll) that the Windows Multiple Provider Notification Application (%SystemRoot%\System32\Mpnotify.exe) calls when the system boots. Mpnotify.exe is itself launched at logon by the Winlogon process.The Citrix notification DLL launches the Ssonvr.exe process asynchronous to the user’s logon:
The only problem with the theory was that Citrix developers insisted that the process did not attempt to load any user registry profile or even read any keys or values from one. Both Microsoft and Citrix were stumped.
Microsoft created a version of Winlogon and the kernel with additional diagnostic information and tried to reproduce the problem on lab systems configured identically to the client’s, but without success. The customer couldn’t even reproduce the problem with the modified Windows images, presumably because the images changed the timing of the system enough to avoid the problem. At this point a Microsoft support engineer suggested that the customer capture a trace of logon activity with Process Monitor.
There are a couple of ways to configure Process Monitor to record logon operations: one is to use Sysinternals PsExec to launch it in the session 0 so that it survives the logoff and subsequent logon and another is to use the boot logging feature to capture activity from early in the boot, including the logon. The engineer chose the latter, so he told the customer to run Process Monitor on one of the system’s that persistently exhibited the problem, select Enable Boot Logging from the Process Monitor Options menu, and reboot, repeating the steps until the problem reproduced. This procedure configures the Process Monitor driver to load early in the boot process and log activity to %SystemRoot%\Procmon.pmb. Once the user logged encountered the issue, they were to run Process Monitor again, at which point the driver would stop logging and Process Monitor would offer to convert the boot log into a standard Process Monitor log file.
After a couple of attempts the user captured a boot log file that they submitted to Microsoft. Microsoft support engineers scanned through the log and came across the sharing violation error when Winlogon tried to load the user’s registry hive:
It was obvious from operations immediately preceding the error that Ssonsvr.exe was the process that had the hive opened. The question was, why was Ssonsvr.exe opening the registry hive? To answer that question the engineers turned to Process Monitor’s stack trace functionality. Process Monitor captures a call stack for every operation, which represents the function call nesting responsible for the operation. By looking at a call stack you can often determine an operation’s root cause when it might not be obvious just from the process that executed it. For example, the stack shows you if a DLL loaded into the process executed the operation and, if you have symbols configured and the call originates in a Windows image or other image for which you have symbols, it will even show you the names of the responsible functions.
The stack for Ssonsvr.exe’s open of the Ntuser.dat file showed that Ssonsvr.exe wasn’t actually responsible for the operation, the Windows Logical Prefetcher was:
Introduced in Windows XP, the Logical Prefetcher is a kernel component that monitors the first ten seconds of a process launch, recording the directories and portions of files accessed by the process during that time to a file it stores in %SystemRoot%\Prefetch. So that multiple executables with the same name but in different directories get their own prefetch file, the Logical Prefetcher gives the file a name that’s a concatenation of the executable image name and the hash of the path in which the image is stored e.g. NOTEPAD.EXE-D8414F97.pf. You can actually see the files and directories the Logical Prefetcher saw an application reference the last time it launched by using the Sysinternals Strings utility to scan a prefetch file like this:
strings <prefetch file>
The next time the application launches, the Logical Prefetcher, executing in the context of the process’s first thread, looks for a prefetch file. If one exists, it opens each directory it lists to bring the directory’s metadata into memory if not already present. The Logical Prefetcher then maps each file listed in the prefetch file and references the portions accessed the last time the application ran so that they also get brought into memory. The Logical Prefetcher can speed up an application launch because it generates large, sequential I/Os instead of issuing small random accesses to file data as the application would typically do during startup.
The implication of the Logical Prefetcher in the profile problem only raised more questions, however. Why was it prefetching the user’s hive file in the context of Ssonsvr.exe when Ssonsvr.exe itself never accesses registry profiles? Microsoft support contacted the Logical Prefetcher’s development team for the answer. The developers first noted that the registry on Windows XP is read into memory using cached file I/O operations, which means that the Cache Manager’s read-ahead thread will proactively read portions of the hive. Since the read-ahead thread executes in the System process, and the Logical Prefetcher associates System process activity with the currently launching process, that a specific timing sequence of process launches and activity during the boot and log on could cause hive accesses to be seen by the Logical Prefetcher as being part of the Ssonsvr.exe launch. If the order was slightly different the next boot and log on, Winlogon might collide with the Logical Prefetcher, as seen in the captured boot log.
The Logical Prefetcher is supposed to execute transparently to other activity on a system, but its file references can lead to sharing violations like this on Windows XP systems (on server systems the Logical Prefetcher only prefetches boot activity, and it does so synchronously before the boot process proceeds). For that reason, on Windows Vista and Windows 7 systems, the Logical Prefetcher makes use of a file system minifilter driver, Fileinfo (%SystemRoot%\System32\Drivers\Fileinfo.sys), to watch for potential sharing violation collisions and prevent them by stalling a second open operation on a file being accessed by the Logical Prefetcher until the Logical Prefetcher closes the file.
Now that the problem was understood, Microsoft and Citrix brainstormed on workarounds customers could apply while Citrix worked on an update to the ICA Client that would prevent the sharing violation. One workaround was to disable application prefetching and another was to write a logoff script that deletes the Ssonsvr.exe prefetch files. Citrix published the workarounds in this Citrix Knowledge Base article and Microsoft in this Microsoft Knowledge Base article. The update to the ICA Client, which was made available a few days later, changed the network provider DLL to 10 seconds after Ssonsvr.exe launches before returning control to Mpnotify.exe. Because Winlogon waits for Mpnotify to exit before logging on a user, the Logical Prefetcher won’t associate Winlogon’s accesses of the user’s hive with Ssonsvr.exe’s startup.
As I said in the introduction, I find this case particularly interesting because it demonstrates a little known Process Monitor feature, boot logging, and the power of stack traces for root cause analysis, two key tools for everyone’s troubleshooting arsenal. It also shows how successful troubleshooting sometimes means coming up with a workaround when there’s no fix or you must wait until a vendor provides one. Another case successfully closed with Process Monitor! Please keep sending me screen shots and log files of the cases you solve.
I have the same issue and I think it it Symantec that causing it. Similar to Andy.
I reached out the Symantec and they don't have any idea. I don't have version 11 to upgrade and test.
Workaround for me is to install UPHClean-Setup.msi
I've seen the same:
unable to mount user hive
=> temporary profile
=> user very confused
On four machines now.
I also used boot logging to track it down.
But I didn't look at the call stacks.
In my cases it was Live Mesh and uninstalling it fixed it. Perhaps it was also the prefetcher though I believe two of the machines were running Vista, one Server 2008, one XP, and the article says this work better in Vista..
At my college we have a lab full of WinXP.
We could never access our profiles, always getting the temps.
Admins just shrugged. We just figured profile support was really bad under WinXP. This for abour 3 years and ongoing.
This kind of "error" had happened to me after I have installed and uninstalled my Kaspersky IS 2009 for many times.
A lot of these issues stem from the fact that we've lost the plot with desktop PC's, in that we've forgotten what the P stands for -and that is IS a P, and not M for mainframe.
It does look like winlogon is saying "something else (prefetch) has the file open, so I can't get exclusive access to it ... fatal error".
I suppose this wouldn't happen if prefetch used something like VSS to access the data, so the file doesn't appear to be in use at all to regular processess.
I'm surprised that prefetch is trying to read ntuser.dat at all. You'd think ntuser.dat (and possibly other files involved in authentication and policy enforcement, or which are data files that might change regularly) would need to be permanently exempted from prefetch.
Like several people that have posted here I want to know why Microsoft did not come up with a prefetching fix that prevent this type of sharing violation in XP?
In this article Mark does a great job of explaining what's going on wtih Citrix and how their company developed a fix for their client however what about all the other applications that may have this problem on XP?
I work for a company that has 1000's of computers and we support about 2500 applications, migrating to a later OS is not an easy option and can take a over year to do so. We see this problem on a daily basis however it is very difficult to predict when and what computer it will occur so setting up the procmon to capture the event has proven very difficult. Setting up procmon after it has happened will not work because the computer requires a reboot for boot logging to begin and rebooting casues the problem to go away.
Unless someone knows how to force the procmon to begin boot logging by only logging out and logging back on?
Workaround for me is to install UPHClean-Setup.msi
This is not working for me. Any more ideas?
Thanks a lot.
Thanx Mark for sharing this with us.
Citrix's fix is such a hack. It add ten seconds to user logon because they made the choice to start a process in a Network Provider dll. Why not just start a thread in the dll that waits ten seconds then starts the Ssonsvr.exe process?
N/M after thinking about it more I realized my above solutions won't work. It's still a hack, though, IMO. While I assume they have very good reasons to do so, the primary problem still appears to me to be the fact that they're using a Network Provider to launch a process at boot time. Rather than hanging boot time (unless I am mistaken that it does), before Ssonsvr.exe stops it should delete its own prefetch file as suggested unless there's another way to disable prefetch for a single file/process.
We had a similar problem with server 2003 x64 (terminalserver). one user gets a lock on ntuser.at. funny thing was that over night the lock was gone and 24 hours later the lock was there again. the prefetch was already disabled, the userprofile was a local one, etc. i captured the whole day/night with procmon and searched through millions of events. finally it was the "wmiprvse.exe" which was started by the Windows Management Instrumentation service. I disabled that (i think the Windows Firewall needs that), nothing, the lock was still there. After a reboot i captured again and voilà, the lock was gone and it didn't come back.
wmiprvse.exe was going through all userprofiles and was touching the ntuser.dat (ask god or bill gate why!). The third time it does that on this one profile, it gets a sharing violation and the profile is locked.
Thanks Mark for that great bunch of tools making my life much easier :-).
This issue also occurred on one of our machines with GoogleUpdater enabled. Google's updating process is especially insidious as in order to fully disable it, one must disable services, delete registry entries and disable or delete scheduled tasks.
Plus it contributes to this Temp Registry Profile problem! Garbageware.
i wish someone would respond to me. i have info of all thats going on. i have gone through all these new problems due to the worm i been fighting since 2008 aug. the main worm is still untouched. and i am still spreading it and cant do anything about it. this registry key situation started off when i tried to block the hacker at the beginning, when i was winning, he changed it so everything said access denied, and later while loggin in, would give himself my status and degrade me 1 step lower. the keys on my machine would be blocked, and at times, would block me from being able to log on to the computer. and i formated so many times.
this worm seems to be above boot, possibly device firmware alterations and bios. anything after that would be beyond me. i been fighting since aug 2008 and still cant rid the worm and want someone to help.
i am affecting computers 24/7 using pings that i cant even touch. help....
this worm is independant of the operating system. and even a low level formating with all devices taken out that emit signals, and new restore disk, and all the extras. when doing all this, the worm is affecting the computer even still. any machine brought into my house gets infected. can anyone help...
and dont tell me to use antivirus, i tried all variations of all antiviruses, firewalls, onestop, and all others. they all dont detect. i have info allowing me to know that the other worms were decoys. no one is responding. if all else, send this to someone who can investigate or at least want to hear the details i have of whats going on.
"Get help from Microsoft
Get online support (or toll-free telephone support in the U.S. and Canada) for security-related issues such as viruses and security updates."