Home
%3CLINGO-SUB%20id%3D%22lingo-sub-723832%22%20slang%3D%22en-US%22%3EThe%20Case%20of%20the%20Temporary%20Registry%20Profiles%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723832%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TechNet%20on%20Aug%2010%2C%202009%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EMicrosoft%20Customer%20Support%20Services%20(CSS)%20is%20one%20of%20the%20biggest%20customers%20of%20the%20Sysinternals%20tools%20and%20they%20often%20send%20me%20interesting%20cases%20they%E2%80%99ve%20solved%20with%20them.%20This%20particular%20case%20is%20especially%20interesting%20because%20it%20affected%20a%20large%20number%20of%20users%20and%20the%20troubleshooting%20process%20made%20use%20of%20one%20of%20%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fsysinternals%2Fbb896645.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Process%20Monitor%E2%80%99s%20%3C%2FA%3E%20lesser-known%20features.%20The%20case%20opened%20when%20a%20customer%20contacted%20Microsoft%20support%20reporting%20that%20several%20of%20their%20users%20would%20occasionally%20get%20this%20error%20message%20when%20loggging%20on%20to%20their%20systems%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22161%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FTheCaseoftheNewLogonRegistryProfiles_DF02%2Fimage_thumb_2.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121159iF5E14BB28D5AAA3B%22%20style%3D%22border-right-width%3A%200px%3B%20display%3A%20inline%3B%20border-top-width%3A%200px%3B%20border-bottom-width%3A%200px%3B%20border-left-width%3A%200px%22%20title%3D%22image%22%20width%3D%22324%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThis%20caused%20Windows%20to%20create%20a%20temporary%20profile%20for%20the%20user%E2%80%99s%20logon%20session.%20A%20user%20profile%20consists%20of%20a%20directory%2C%20%25UserProfile%25%2C%20into%20which%20applications%20save%20user-specific%20configuration%20and%20data%20files%2C%20as%20well%20as%20a%20registry%20hive%20file%20stored%20in%20that%20directory%2C%20%25UserProfile%25%5CNtuser.dat%2C%20that%20the%20Winlogon%20process%20loads%20when%20the%20user%20logs%20in.%20Applications%20store%20user%20settings%20in%20the%20registry%20hive%20by%20calling%20registry%20functions%20that%20refer%20to%20the%20HKEY_CURRENT_USER%20(HKCU)%20root%20key.%20The%20user%E2%80%99s%20loss%20of%20access%20to%20their%20profile%20made%20the%20problem%20critical%2C%20because%20whenever%20that%20happened%2C%20the%20user%20would%20apparently%20lose%20all%20their%20settings%20and%20access%20to%20files%20stored%20in%20their%20profile%20directory.%20In%20most%20cases%2C%20users%20contacted%20the%20company%E2%80%99s%20support%20desk%2C%20which%20would%20ask%20the%20user%20to%20try%20rebooting%20and%20logging%20in%20until%20the%20problem%20resolved%20itself.%3C%2FP%3E%0A%20%20%3CP%3EAs%20with%20all%20cases%2C%20Microsoft%20support%20began%20by%20asking%20about%20the%20system%20configuration%2C%20inventory%20of%20installed%20software%2C%20and%20about%20any%20recent%20changes%20the%20company%20had%20made%20to%20their%20systems.%20In%20this%20case%2C%20the%20fact%20that%20stood%20out%20was%20that%20all%20the%20systems%20on%20which%20the%20problem%20had%20occurred%20had%20recently%20been%20upgraded%20to%20a%20new%20version%20of%20Citrix%20Corporation's%20ICA%20client%2C%20a%20remote%20desktop%20application.%20Microsoft%20contacted%20Citrix%20support%20to%20see%20if%20they%20knew%20of%20any%20issues%20with%20the%20new%20client.%20They%20didn%E2%80%99t%2C%20but%20said%20they%20would%20investigate.%3C%2FP%3E%0A%20%20%3CP%3EUnsure%20whether%20the%20ICA%20client%20upgrade%20was%20responsible%20for%20the%20profile%20problem%2C%20Microsoft%20support%20instructed%20the%20customer%20to%20enable%20profile%20logging%2C%20which%20you%20can%20do%20by%20configuring%20a%20registry%20key%20as%20per%20this%20Knowledge%20Base%20article%3A%20%3CA%20href%3D%22http%3A%2F%2Fsupport.microsoft.com%2Fkb%2F221833%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20How%20to%20enable%20user%20environment%20debug%20logging%20in%20retail%20builds%20of%20Windows%20%3C%2FA%3E%20.%20The%20customer%20pushed%20a%20script%20out%20to%20their%20systems%20to%20make%20the%20required%20registry%20changes%20and%20shortly%20after%20got%20another%20call%20from%20a%20user%20with%20the%20profile%20problem.%20They%20grabbed%20a%20copy%20of%20the%20profile%20log%20off%20the%20system%20from%20%25SystemRoot%25%5CDebug%5CUserMode%5CUserenv.log%20and%20sent%20it%20into%20Microsoft.%20The%20log%20was%20inconclusive%2C%20but%20did%20provide%20an%20important%20clue%3A%20it%20indicated%20that%20the%20user%E2%80%99s%20profile%20had%20failed%20to%20load%20because%20of%20error%2032%2C%20which%20is%20%3CA%20href%3D%22http%3A%2F%2Fsupport.microsoft.com%2Fkb%2F316609%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20ERROR_SHARING_VIOLATION%20%3C%2FA%3E%20%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%2270%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FTheCaseoftheNewLogonRegistryProfiles_DF02%2Fimage_thumb.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121160i97F72B62C0E964C4%22%20style%3D%22border-right-width%3A%200px%3B%20display%3A%20inline%3B%20border-top-width%3A%200px%3B%20border-bottom-width%3A%200px%3B%20border-left-width%3A%200px%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EWhen%20a%20process%20opens%20a%20file%2C%20it%20specifies%20what%20kinds%20of%20sharing%20it%20allows%20for%20the%20file.%20If%20it%20is%20writing%20to%20the%20file%20it%20may%20allow%20other%20processes%20to%20read%20from%20the%20file%2C%20for%20example%2C%20but%20not%20to%20also%20write%20to%20the%20file.%20The%20sharing%20violation%20in%20the%20log%20file%20meant%20that%20another%20process%20had%20opened%20the%20user%E2%80%99s%20registry%20hive%20in%20a%20way%20that%20was%20incompatible%20with%20the%20way%20that%20the%20logon%20process%20wanted%20to%20open%20the%20file.%3C%2FP%3E%0A%20%20%3CP%3EIn%20the%20meantime%2C%20more%20customers%20around%20the%20world%20began%20contacting%20Microsoft%20and%20Citrix%20with%20the%20same%20issue%2C%20all%20had%20also%20deployed%20the%20new%20ICA%20client.%20Citrix%20support%20then%20reported%20that%20they%20suspected%20that%20the%20sharing%20violation%20might%20be%20caused%20by%20one%20of%20the%20ICA%20client%E2%80%99s%20processes%2C%20Ssonvr.exe.%20During%20installation%2C%20the%20ICA%20client%20registers%20a%20Network%20Provider%20DLL%20(Pnsson.dll)%20that%20the%20Windows%20Multiple%20Provider%20Notification%20Application%20(%25SystemRoot%25%5CSystem32%5CMpnotify.exe)%20calls%20when%20the%20system%20boots.%20Mpnotify.exe%20is%20itself%20launched%20at%20logon%20by%20the%20Winlogon%20process.The%20Citrix%20notification%20DLL%20launches%20the%20Ssonvr.exe%20process%20asynchronous%20to%20the%20user%E2%80%99s%20logon%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22264%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FTheCaseoftheNewLogonRegistryProfiles_DF02%2Fimage_thumb_6.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121161i6CDB52EC6B0D1402%22%20style%3D%22border-right-width%3A%200px%3B%20display%3A%20inline%3B%20border-top-width%3A%200px%3B%20border-bottom-width%3A%200px%3B%20border-left-width%3A%200px%22%20title%3D%22image%22%20width%3D%22450%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20only%20problem%20with%20the%20theory%20was%20that%20Citrix%20developers%20insisted%20that%20the%20process%20did%20not%20attempt%20to%20load%20any%20user%20registry%20profile%20or%20even%20read%20any%20keys%20or%20values%20from%20one.%20Both%20Microsoft%20and%20Citrix%20were%20stumped.%3C%2FP%3E%0A%20%20%3CP%3EMicrosoft%20created%20a%20version%20of%20Winlogon%20and%20the%20kernel%20with%20additional%20diagnostic%20information%20and%20tried%20to%20reproduce%20the%20problem%20on%20lab%20systems%20configured%20identically%20to%20the%20client%E2%80%99s%2C%20but%20without%20success.%20The%20customer%20couldn%E2%80%99t%20even%20reproduce%20the%20problem%20with%20the%20modified%20Windows%20images%2C%20presumably%20because%20the%20images%20changed%20the%20timing%20of%20the%20system%20enough%20to%20avoid%20the%20problem.%20At%20this%20point%20a%20Microsoft%20support%20engineer%20suggested%20that%20the%20customer%20capture%20a%20trace%20of%20logon%20activity%20with%20Process%20Monitor.%3C%2FP%3E%0A%20%20%3CP%3EThere%20are%20a%20couple%20of%20ways%20to%20configure%20Process%20Monitor%20to%20record%20logon%20operations%3A%20one%20is%20to%20use%20%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fsysinternals%2Fbb897553.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Sysinternals%20PsExec%20%3C%2FA%3E%20to%20launch%20it%20in%20the%20session%200%20so%20that%20it%20survives%20the%20logoff%20and%20subsequent%20logon%20and%20another%20is%20to%20use%20the%20boot%20logging%20feature%20to%20capture%20activity%20from%20early%20in%20the%20boot%2C%20including%20the%20logon.%20The%20engineer%20chose%20the%20latter%2C%20so%20he%20told%20the%20customer%20to%20run%20Process%20Monitor%20on%20one%20of%20the%20system%E2%80%99s%20that%20persistently%20exhibited%20the%20problem%2C%20select%20Enable%20Boot%20Logging%20from%20the%20Process%20Monitor%20Options%20menu%2C%20and%20reboot%2C%20repeating%20the%20steps%20until%20the%20problem%20reproduced.%20This%20procedure%20configures%20the%20Process%20Monitor%20driver%20to%20load%20early%20in%20the%20boot%20process%20and%20log%20activity%20to%20%25SystemRoot%25%5CProcmon.pmb.%20Once%20the%20user%20logged%20encountered%20the%20issue%2C%20they%20were%20to%20run%20Process%20Monitor%20again%2C%20at%20which%20point%20the%20driver%20would%20stop%20logging%20and%20Process%20Monitor%20would%20offer%20to%20convert%20the%20boot%20log%20into%20a%20standard%20Process%20Monitor%20log%20file.%3C%2FP%3E%0A%20%20%3CP%3EAfter%20a%20couple%20of%20attempts%20the%20user%20captured%20a%20boot%20log%20file%20that%20they%20submitted%20to%20Microsoft.%20Microsoft%20support%20engineers%20scanned%20through%20the%20log%20and%20came%20across%20the%20sharing%20violation%20error%20when%20Winlogon%20tried%20to%20load%20the%20user%E2%80%99s%20registry%20hive%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22114%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FTheCaseoftheNewLogonRegistryProfiles_DF02%2Fimage_thumb_3.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121162i3A3F779C738EB387%22%20style%3D%22border-right-width%3A%200px%3B%20display%3A%20inline%3B%20border-top-width%3A%200px%3B%20border-bottom-width%3A%200px%3B%20border-left-width%3A%200px%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EIt%20was%20obvious%20from%20operations%20immediately%20preceding%20the%20error%20that%20Ssonsvr.exe%20was%20the%20process%20that%20had%20the%20hive%20opened.%20The%20question%20was%2C%20why%20was%20Ssonsvr.exe%20opening%20the%20registry%20hive%3F%20To%20answer%20that%20question%20the%20engineers%20turned%20to%20Process%20Monitor%E2%80%99s%20stack%20trace%20functionality.%20Process%20Monitor%20captures%20a%20call%20stack%20for%20every%20operation%2C%20which%20represents%20the%20function%20call%20nesting%20responsible%20for%20the%20operation.%20By%20looking%20at%20a%20call%20stack%20you%20can%20often%20determine%20an%20operation%E2%80%99s%20root%20cause%20when%20it%20might%20not%20be%20obvious%20just%20from%20the%20process%20that%20executed%20it.%20For%20example%2C%20the%20stack%20shows%20you%20if%20a%20DLL%20loaded%20into%20the%20process%20executed%20the%20operation%20and%2C%20if%20you%20have%20symbols%20configured%20and%20the%20call%20originates%20in%20a%20Windows%20image%20or%20other%20image%20for%20which%20you%20have%20symbols%2C%20it%20will%20even%20show%20you%20the%20names%20of%20the%20responsible%20functions.%3C%2FP%3E%0A%20%20%3CP%3EThe%20stack%20for%20Ssonsvr.exe%E2%80%99s%20open%20of%20the%20Ntuser.dat%20file%20showed%20that%20Ssonsvr.exe%20wasn%E2%80%99t%20actually%20responsible%20for%20the%20operation%2C%20the%20Windows%20Logical%20Prefetcher%20was%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22170%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FTheCaseoftheNewLogonRegistryProfiles_DF02%2Fimage_thumb_4.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121163i215FCDD4E6E657EB%22%20style%3D%22border-right-width%3A%200px%3B%20display%3A%20inline%3B%20border-top-width%3A%200px%3B%20border-bottom-width%3A%200px%3B%20border-left-width%3A%200px%22%20title%3D%22image%22%20width%3D%22429%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EIntroduced%20in%20Windows%20XP%2C%20the%20Logical%20Prefetcher%20is%20a%20kernel%20component%20that%20monitors%20the%20first%20ten%20seconds%20of%20a%20process%20launch%2C%20recording%20the%20directories%20and%20portions%20of%20files%20accessed%20by%20the%20process%20during%20that%20time%20to%20a%20file%20it%20stores%20in%20%25SystemRoot%25%5CPrefetch.%20So%20that%20multiple%20executables%20with%20the%20same%20name%20but%20in%20different%20directories%20get%20their%20own%20prefetch%20file%2C%20the%20Logical%20Prefetcher%20gives%20the%20file%20a%20name%20that%E2%80%99s%20a%20concatenation%20of%20the%20executable%20image%20name%20and%20the%20hash%20of%20the%20path%20in%20which%20the%20image%20is%20stored%20e.g.%20NOTEPAD.EXE-D8414F97.pf.%20You%20can%20actually%20see%20the%20files%20and%20directories%20the%20Logical%20Prefetcher%20saw%20an%20application%20reference%20the%20last%20time%20it%20launched%20by%20using%20the%20Sysinternals%20%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fsysinternals%2Fbb897439.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Strings%20%3C%2FA%3E%20utility%20to%20scan%20a%20prefetch%20file%20like%20this%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CFONT%20face%3D%22Courier%20New%22%3E%20strings%20%3CPREFETCH%20file%3D%22%22%3E%20%3C%2FPREFETCH%3E%3C%2FFONT%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20next%20time%20the%20application%20launches%2C%20the%20Logical%20Prefetcher%2C%20executing%20in%20the%20context%20of%20the%20process%E2%80%99s%20first%20thread%2C%20looks%20for%20a%20prefetch%20file.%20If%20one%20exists%2C%20it%20opens%20each%20directory%20it%20lists%20to%20bring%20the%20directory%E2%80%99s%20metadata%20into%20memory%20if%20not%20already%20present.%20The%20Logical%20Prefetcher%20then%20maps%20each%20file%20listed%20in%20the%20prefetch%20file%20and%20references%20the%20portions%20accessed%20the%20last%20time%20the%20application%20ran%20so%20that%20they%20also%20get%20brought%20into%20memory.%20The%20Logical%20Prefetcher%20can%20speed%20up%20an%20application%20launch%20because%20it%20generates%20large%2C%20sequential%20I%2FOs%20instead%20of%20issuing%20small%20random%20accesses%20to%20file%20data%20as%20the%20application%20would%20typically%20do%20during%20startup.%3C%2FP%3E%0A%20%20%3CP%3EThe%20implication%20of%20the%20Logical%20Prefetcher%20in%20the%20profile%20problem%20only%20raised%20more%20questions%2C%20however.%20Why%20was%20it%20prefetching%20the%20user%E2%80%99s%20hive%20file%20in%20the%20context%20of%20Ssonsvr.exe%20when%20Ssonsvr.exe%20itself%20never%20accesses%20registry%20profiles%3F%20Microsoft%20support%20contacted%20the%20Logical%20Prefetcher%E2%80%99s%20development%20team%20for%20the%20answer.%20The%20developers%20first%20noted%20that%20the%20registry%20on%20Windows%20XP%20is%20read%20into%20memory%20using%20cached%20file%20I%2FO%20operations%2C%20which%20means%20that%20the%20Cache%20Manager%E2%80%99s%20read-ahead%20thread%20will%20proactively%20read%20portions%20of%20the%20hive.%20Since%20the%20read-ahead%20thread%20executes%20in%20the%20System%20process%2C%20and%20the%20Logical%20Prefetcher%20associates%20System%20process%20activity%20with%20the%20currently%20launching%20process%2C%20that%20a%20specific%20timing%20sequence%20of%20process%20launches%20and%20activity%20during%20the%20boot%20and%20log%20on%20could%20cause%20hive%20accesses%20to%20be%20seen%20by%20the%20Logical%20Prefetcher%20as%20being%20part%20of%20the%20Ssonsvr.exe%20launch.%20If%20the%20order%20was%20slightly%20different%20the%20next%20boot%20and%20log%20on%2C%20Winlogon%20might%20collide%20with%20the%20Logical%20Prefetcher%2C%20as%20seen%20in%20the%20captured%20boot%20log.%3C%2FP%3E%0A%20%20%3CP%3EThe%20Logical%20Prefetcher%20is%20supposed%20to%20execute%20transparently%20to%20other%20activity%20on%20a%20system%2C%20but%20its%20file%20references%20can%20lead%20to%20sharing%20violations%20like%20this%20on%20Windows%20XP%20systems%20(on%20server%20systems%20the%20Logical%20Prefetcher%20only%20prefetches%20boot%20activity%2C%20and%20it%20does%20so%20synchronously%20before%20the%20boot%20process%20proceeds).%20For%20that%20reason%2C%20on%20Windows%20Vista%20and%20Windows%207%20systems%2C%20the%20Logical%20Prefetcher%20makes%20use%20of%20a%20file%20system%20minifilter%20driver%2C%20Fileinfo%20(%25SystemRoot%25%5CSystem32%5CDrivers%5CFileinfo.sys)%2C%20to%20watch%20for%20potential%20sharing%20violation%20collisions%20and%20prevent%20them%20by%20stalling%20a%20second%20open%20operation%20on%20a%20file%20being%20accessed%20by%20the%20Logical%20Prefetcher%20until%20the%20Logical%20Prefetcher%20closes%20the%20file.%3C%2FP%3E%0A%20%20%3CP%3ENow%20that%20the%20problem%20was%20understood%2C%20Microsoft%20and%20Citrix%20brainstormed%20on%20workarounds%20customers%20could%20apply%20while%20Citrix%20worked%20on%20an%20update%20to%20the%20ICA%20Client%20that%20would%20prevent%20the%20sharing%20violation.%20One%20workaround%20was%20to%20disable%20application%20prefetching%20and%20another%20was%20to%20write%20a%20logoff%20script%20that%20deletes%20the%20Ssonsvr.exe%20prefetch%20files.%20Citrix%20published%20the%20workarounds%20in%20this%20%3CA%20href%3D%22http%3A%2F%2Fsupport.citrix.com%2Farticle%2FCTX118226%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Citrix%20Knowledge%20Base%20%3C%2FA%3E%20article%20and%20Microsoft%20in%20this%20%3CA%20href%3D%22http%3A%2F%2Fsupport.microsoft.com%2Fkb%2F969100%2Fen-us%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Microsoft%20Knowledge%20Base%20%3C%2FA%3E%20article.%20The%20update%20to%20the%20ICA%20Client%2C%20which%20was%20made%20available%20a%20few%20days%20later%2C%20changed%20the%20network%20provider%20DLL%20to%2010%20seconds%20after%20Ssonsvr.exe%20launches%20before%20returning%20control%20to%20Mpnotify.exe.%20Because%20Winlogon%20waits%20for%20Mpnotify%20to%20exit%20before%20logging%20on%20a%20user%2C%20the%20Logical%20Prefetcher%20won%E2%80%99t%20associate%20Winlogon%E2%80%99s%20accesses%20of%20the%20user%E2%80%99s%20hive%20with%20Ssonsvr.exe%E2%80%99s%20startup.%3C%2FP%3E%0A%20%20%3CP%3EAs%20I%20said%20in%20the%20introduction%2C%20I%20find%20this%20case%20particularly%20interesting%20because%20it%20demonstrates%20a%20little%20known%20Process%20Monitor%20feature%2C%20boot%20logging%2C%20and%20the%20power%20of%20stack%20traces%20for%20root%20cause%20analysis%2C%20two%20key%20tools%20for%20everyone%E2%80%99s%20troubleshooting%20arsenal.%20It%20also%20shows%20how%20successful%20troubleshooting%20sometimes%20means%20coming%20up%20with%20a%20workaround%20when%20there%E2%80%99s%20no%20fix%20or%20you%20must%20wait%20until%20a%20vendor%20provides%20one.%20Another%20case%20successfully%20closed%20with%20Process%20Monitor!%20Please%20keep%20sending%20me%20screen%20shots%20and%20log%20files%20of%20the%20cases%20you%20solve.%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-723832%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TechNet%20on%20Aug%2010%2C%202009%20Microsoft%20Customer%20Support%20Services%20(CSS)%20is%20one%20of%20the%20biggest%20customers%20of%20the%20Sysinternals%20tools%20and%20they%20often%20send%20me%20interesting%20cases%20they%E2%80%99ve%20solved%20with%20them.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-723832%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMark%20Russinovich%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on TechNet on Aug 10, 2009

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:

image

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 :

image

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:

image

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:

image

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:

image

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.