|
| 1 | +--- |
| 2 | +title: Virtual Machine is unresponsive while applying 'Group Policy Local Users & Groups' policy |
| 3 | +description: This article provides steps to resolve issues where the load screen is stuck applying a policy during boot in an Azure Virtual Machine (VM). |
| 4 | +services: virtual-machines-windows |
| 5 | +documentationcenter: '' |
| 6 | +author: v-miegge |
| 7 | +manager: dcscontentpm |
| 8 | +editor: '' |
| 9 | +tags: azure-resource-manager |
| 10 | +ms.assetid: ff113268-f5bf-4e6a-986e-63b9b0ceff20 |
| 11 | +ms.service: virtual-machines-windows |
| 12 | +ms.workload: infrastructure-services |
| 13 | +ms.tgt_pltfrm: na |
| 14 | +ms.topic: troubleshooting |
| 15 | +ms.date: 04/02/2020 |
| 16 | +ms.author: v-mibufo |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +# Virtual Machine is unresponsive while applying 'Group Policy Local Users & Groups' policy |
| 21 | + |
| 22 | +This article provides steps to resolve issues where the load screen is stuck applying a policy, during boot, in an Azure Virtual Machine (VM). |
| 23 | + |
| 24 | +## Symptom |
| 25 | + |
| 26 | +When you use [Boot diagnostics](https://docs.microsoft.com/azure/virtual-machines/troubleshooting/boot-diagnostics) to view the screenshot of the VM, you'll see that the screen is stuck loading with the message: *Applying Group Policy Local Users and Groups policy*. |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +Windows Server 2012 |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +Windows Server 2012 R2 |
| 35 | + |
| 36 | +## Cause |
| 37 | + |
| 38 | +The symptoms of this freeze are caused by a code defect in the Windows Profile Service Dynamic Link Library (*profsvc.dll*). |
| 39 | + |
| 40 | +> [!NOTE] |
| 41 | +> This defect applies only on Windows Server 2012 and Windows Server 2012 R2. |
| 42 | +
|
| 43 | +### The policy in question |
| 44 | + |
| 45 | +The policy being applied that won't finish its processes is: |
| 46 | + |
| 47 | +* *Computer Configuration\Policies\Administrative Templates\System/User Profiles\Delete user profiles older than a specified number of days on system restart* |
| 48 | + |
| 49 | +This policy will only hang if the following six conditions are true: |
| 50 | + |
| 51 | +* The *Delete user profiles older than a specified number of days on system restart* policy is enabled. |
| 52 | +* You have profiles that have met the age requirements to require cleanup. |
| 53 | +* You have components that have registered for delete notification for profiles. |
| 54 | +* The components make calls (direct or indirect) that need to acquire data from the Service Control Manager (SCM) components of Windows, such as Start, Stop, or Query information about a service. |
| 55 | +* You have a service configured to start as *automatic*. |
| 56 | +* This service is set to run under the context of a domain account (as opposed to using a built-in account, such as a local system). |
| 57 | + |
| 58 | +### The code defect |
| 59 | + |
| 60 | +The code defect is due to the Service Control Manager (SCM) and the Profile services attempting to apply locks on one another simultaneously. Locks exist to prevent multiple services from making changes on the same data at the same time, which would cause corruption. Ordinarily, multiple lock requests wouldn't cause an issue. However, since this is happening during boot, neither service can complete their processes, as they are stuck waiting upon one another. |
| 61 | + |
| 62 | +### OS Bug 5880648 - Service Control Manager deadlocks with the "Delete user profiles on restart" policy |
| 63 | + |
| 64 | +There are two actions which overlap so that: |
| 65 | + |
| 66 | +* Action 1 acquires the profile lock but has not yet acquired the SCM lock. |
| 67 | + |
| 68 | + **AND** |
| 69 | + |
| 70 | +* Action 2 acquires the SCM lock but has not yet acquired the profile lock. |
| 71 | + |
| 72 | +Once this deadlock occurs, the attempt to acquire the second required lock hangs the action. |
| 73 | + |
| 74 | +### Action 1 - Old profile deletion notification (has **Profile Lock**, needs **SCM Lock**) |
| 75 | + |
| 76 | +1. First, the policy set to delete old profiles acquires an internal profile service lock. |
| 77 | + |
| 78 | + * This lock is there to prevent two threads from interacting with the profiles while the *delete operation* is progress. |
| 79 | + |
| 80 | +2. The policy finds profiles that are old enough to be deleted. |
| 81 | +3. As part of the profile deletion, a component that has registered for notifications of the deletions of a profile tries to **start a service**. |
| 82 | +4. Prior to starting the service, the Service Control Manager (SCM) needs to acquire an **internal SCM lock** held by threads in **Action 2**. |
| 83 | + |
| 84 | +### Action 2 - Profile load/creation for user specific data (has **SCM Lock**, needs **Profile Lock**) |
| 85 | + |
| 86 | +1. At boot, SCM needs to order all *auto-start* services by their group, as well as any services that those services are dependent upon. |
| 87 | + |
| 88 | +2. **SCM acquires an internal SCM lock** used to control access to starting, stopping, or configuring services as it orders the services. |
| 89 | + |
| 90 | +3. Once the services are in order, the SCM loops through each service and starts it. |
| 91 | + |
| 92 | +4. If the service is running under the context of a domain account, a profile needs to be either loaded or created for the domain account, so that it can store user specific data. |
| 93 | + |
| 94 | +5. This request is sent to the **Profile Service**. |
| 95 | + |
| 96 | +6. The profile service needs access to the **internal lock** acquired in **Action 1**. |
| 97 | + |
| 98 | +## Solution |
| 99 | + |
| 100 | +### Process Overview |
| 101 | + |
| 102 | +1. Create and Access a Repair VM |
| 103 | +2. Enable Serial Console and Memory Dump Collection |
| 104 | +3. Rebuild the VM |
| 105 | +4. Collect the Memory Dump File |
| 106 | + |
| 107 | + > [!NOTE] |
| 108 | + > When encountering this boot error, the Guest OS is not operational. You'll be troubleshooting in Offline mode to resolve this issue. |
| 109 | +
|
| 110 | +### Create and Access a Repair VM |
| 111 | + |
| 112 | +1. Use [steps 1-3 of the VM Repair Commands](https://docs.microsoft.com/azure/virtual-machines/troubleshooting/repair-windows-vm-using-azure-virtual-machine-repair-commands#repair-process-example) to prepare a Repair VM. |
| 113 | +2. Using Remote Desktop Connection connect to the Repair VM. |
| 114 | + |
| 115 | +### Enable Serial Console and Memory Dump Collection |
| 116 | + |
| 117 | +To enable memory dump collection and Serial Console, run the script below: |
| 118 | + |
| 119 | +1. Open an elevated command prompt session (Run as administrator). |
| 120 | +2. Run the following commands: |
| 121 | + |
| 122 | + * Enable Serial Console: |
| 123 | + |
| 124 | + `bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /ems {<BOOT LOADER IDENTIFIER>} ON` |
| 125 | + |
| 126 | + `bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /emssettings EMSPORT:1 EMSBAUDRATE:115200` |
| 127 | + |
| 128 | +3. Verify that the free space on the OS disk is as much as the memory size (RAM) on the VM. |
| 129 | + |
| 130 | + * If there's not enough space on the OS disk, you should change the location where the memory dump file will be created and refer that to any data disk attached to the VM that has enough free space. To change the location, replace `%SystemRoot%` with the drive letter (such as "F:") of the data disk in the below commands. |
| 131 | + |
| 132 | +#### Suggested configuration to enable OS Dump |
| 133 | + |
| 134 | +**Load Broken OS Disk:** |
| 135 | + |
| 136 | +`REG LOAD HKLM\BROKENSYSTEM <VOLUME LETTER OF BROKEN OS DISK>:\windows\system32\config\SYSTEM` |
| 137 | + |
| 138 | +**Enable on ControlSet001:** |
| 139 | + |
| 140 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 1 /f` |
| 141 | + |
| 142 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "%SystemRoot%\MEMORY.DMP" /f` |
| 143 | + |
| 144 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v NMICrashDump /t REG_DWORD /d 1 /f` |
| 145 | + |
| 146 | +**Enable on ControlSet002:** |
| 147 | + |
| 148 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 1 /f` |
| 149 | + |
| 150 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "%SystemRoot%\MEMORY.DMP" /f` |
| 151 | + |
| 152 | +`REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v NMICrashDump /t REG_DWORD /d 1 /f` |
| 153 | + |
| 154 | +### Rebuild the VM |
| 155 | + |
| 156 | +Use [step 5 of the VM Repair Commands](https://docs.microsoft.com/azure/virtual-machines/troubleshooting/repair-windows-vm-using-azure-virtual-machine-repair-commands#repair-process-example) to reassemble the VM. |
| 157 | + |
| 158 | +### Collect the Memory Dump File |
| 159 | + |
| 160 | +To resolve this problem, you would need first to gather the memory dump file for the crash and contact support with the memory dump file. To collect the dump file, follow these steps: |
| 161 | + |
| 162 | +#### Attach the OS disk to a new Repair VM |
| 163 | + |
| 164 | +1. Use steps [1-3 of the VM Repair Commands](https://docs.microsoft.com/azure/virtual-machines/troubleshooting/repair-windows-vm-using-azure-virtual-machine-repair-commands#repair-process-example) to prepare a new Repair VM. |
| 165 | + |
| 166 | +2. Using Remote Desktop Connection connect to the Repair VM. |
| 167 | + |
| 168 | +#### Locate the dump file and submit a support ticket |
| 169 | + |
| 170 | +1. On the repair VM, go to windows folder in the attached OS disk. If the driver letter that is assigned to the attached OS disk is F, you need to go to F:\Windows. |
| 171 | + |
| 172 | +2. Locate the memory.dmp file, and then [submit a support ticket](https://portal.azure.com/?#blade/Microsoft_Azure_Support/HelpAndSupportBlade) with the memory dump file. |
| 173 | + |
| 174 | +3. If you are having trouble locating the memory.dmp file, you may wish to use [non-maskable interrupt (NMI) calls in serial console](https://docs.microsoft.com/azure/virtual-machines/troubleshooting/serial-console-windows#use-the-serial-console-for-nmi-calls) instead. You can follow the guide to [generate a kernel or complete crash dump](https://docs.microsoft.com/windows/client-management/generate-kernel-or-complete-crash-dump) file using NMI calls. |
0 commit comments