Blue screen error on win11
The blue screen error occurred when I shut down the computer, and it has already happened twice. The following is the minidump file which seems to be related to btrfs. I hope this file can be helpful.
Thanks. It looks like this is a Verifier error, it shouldn't happen when using Windows normally...
DRIVER_VERIFIER_IOMANAGER_VIOLATION (c9)
The IO manager has caught a misbehaving driver.
Arguments:
Arg1: 0000000000000201, A device is deleting itself while there is another device beneath it in the
driver stack. This may be because the caller has forgotten to call
IoDetachDevice first, or the lower driver may have incorrectly deleted itself.
Arg2: fffff80407c85e96, The address in the driver's code where the error was detected.
Arg3: 0000000000000000
Arg4: 0000000000000000
Debugging Details:
------------------
KEY_VALUES_STRING: 1
Key : Analysis.CPU.mSec
Value: 2233
Key : Analysis.DebugAnalysisManager
Value: Create
Key : Analysis.Elapsed.mSec
Value: 2218
Key : Analysis.Init.CPU.mSec
Value: 2889
Key : Analysis.Init.Elapsed.mSec
Value: 40735
Key : Analysis.Memory.CommitPeak.Mb
Value: 103
FILE_IN_CAB: 072323-12265-01.dmp
DUMP_FILE_ATTRIBUTES: 0x1008
Kernel Generated Triage Dump
BUGCHECK_CODE: c9
BUGCHECK_P1: 201
BUGCHECK_P2: fffff80407c85e96
BUGCHECK_P3: 0
BUGCHECK_P4: 0
DRIVER_VERIFIER_IO_VIOLATION_TYPE: 201
BLACKBOXBSD: 1 (!blackboxbsd)
BLACKBOXNTFS: 1 (!blackboxntfs)
BLACKBOXPNP: 1 (!blackboxpnp)
BLACKBOXWINLOGON: 1
CUSTOMER_CRASH_COUNT: 1
PROCESS_NAME: System
STACK_TEXT:
ffff8305`dacff338 fffff802`5accf3d1 : 00000000`000000c9 00000000`00000201 fffff804`07c85e96 00000000`00000000 : nt!KeBugCheckEx
ffff8305`dacff340 fffff802`5acd5840 : 00000000`00000000 00000000`00000000 00000000`00000201 fffff802`5af67d90 : nt!VerifierBugCheckIfAppropriate+0x14d
ffff8305`dacff3e0 fffff802`5acd434b : ffffbd01`7888bbc0 fffff802`5b527bd1 ffffbd01`7888e2e0 ffff8305`dacff000 : nt!ViErrorFinishReport+0x11c
ffff8305`dacff440 fffff802`5acc369d : fffff804`07d3ce10 ffffbd01`83facdd0 ffffbd01`7888bbc0 ffffe287`414052e0 : nt!VfIoDeleteDevice+0x137
ffff8305`dacff4d0 fffff802`5a68565b : ffffbd01`334e6f49 ffffbd01`7888bbc0 ffffe287`00000003 00000000`00000090 : nt!IovDeleteDevice+0x9
ffff8305`dacff500 fffff804`07c85e96 : ffffbd01`00000078 ffffbd01`75c23be0 ffffbd01`7888bbc0 00000000`00000090 : nt!IoDeleteDevice+0x2708cb
ffff8305`dacff530 fffff804`07c1df6a : ffffbd01`6f511f40 ffffbd01`7888bbc0 ffffbd01`78acc660 fffff802`5b527bd1 : btrfs!free_vol+0x106 [Z:\home\hellas\wine\fs\btrfs\src\volume.c @ 91]
ffff8305`dacff560 fffff804`07c1f342 : ffffbd01`83facdd0 00000000`00000000 ffffbd01`7595c530 ffffbd01`81f29da0 : btrfs!do_shutdown+0x18a [Z:\home\hellas\wine\fs\btrfs\src\btrfs.c @ 5444]
ffff8305`dacff5d0 fffff802`5a413247 : ffffbd01`83facdd0 ffffbd01`75b74e00 ffffbd01`759ea538 fffff802`5b52311f : btrfs!drv_shutdown+0x42 [Z:\home\hellas\wine\fs\btrfs\src\btrfs.c @ 5522]
ffff8305`dacff600 fffff802`5acc322f : ffffbd01`759ea538 fffff802`5b57b7cd ffffbd01`759ea5a0 ffffbd01`75b74e00 : nt!IopfCallDriver+0x53
ffff8305`dacff640 fffff802`5a664647 : ffffbd01`785d0bc0 fffff802`5aca789e 00000000`00000000 00000000`00000000 : nt!IovCallDriver+0x5f
ffff8305`dacff680 fffff802`5b527bd1 : ffffbd01`785d0bc0 ffffbd01`785d0bc0 ffffbd01`83facdd0 fffff802`5ae3dee0 : nt!IofCallDriver+0x18ef57
ffff8305`dacff6c0 fffff802`5a413247 : ffffbd01`83facdd0 00000000`00000000 fffff802`5ae3dee0 fffff802`5a9a8608 : FLTMGR!FltpDispatch+0xd1
ffff8305`dacff720 fffff802`5acc322f : 00000000`00000000 ffff8305`dacff820 fffff802`5aca788e 00000000`00000001 : nt!IopfCallDriver+0x53
ffff8305`dacff760 fffff802`5a664647 : ffffbd01`785d0bc0 ffff8305`dacff8d0 00000000`00000000 00000000`00000000 : nt!IovCallDriver+0x5f
ffff8305`dacff7a0 fffff802`5aca789e : ffffbd01`75b74e50 fffff802`5ae5f5e0 00000000`00000000 fffff802`5ae3dee0 : nt!IofCallDriver+0x18ef57
ffff8305`dacff7e0 fffff802`5aca75d3 : 00000000`00000001 ffffbd01`6f6a7bb0 ffffbd01`75b9db00 00000000`00000000 : nt!IopShutdownBaseFileSystems+0xca
ffff8305`dacff860 fffff802`5acac8de : 00000000`00000002 00000000`00000002 fffff802`5af4bac0 fffff802`5af4bac0 : nt!IoShutdownSystem+0x1ab
ffff8305`dacff8e0 fffff802`5a5546e5 : ffffbd01`6f6a7bb0 ffff8305`dacffa00 ffffbd01`00000000 ffffbd01`00000000 : nt!PopGracefulShutdown+0x26e
ffff8305`dacff940 fffff802`5a5589f7 : ffffbd01`8b4a6080 00000000`0000063c ffffbd01`8b4a6080 fffff802`5a554590 : nt!ExpWorkerThread+0x155
ffff8305`dacffb30 fffff802`5a635be4 : ffff9780`fd392180 ffffbd01`8b4a6080 fffff802`5a5589a0 00000000`00000246 : nt!PspSystemThreadStartup+0x57
ffff8305`dacffb80 00000000`00000000 : ffff8305`dad00000 ffff8305`dacf9000 00000000`00000000 00000000`00000000 : nt!KiStartSystemThread+0x34
FAULTING_SOURCE_LINE: Z:\home\hellas\wine\fs\btrfs\src\volume.c
FAULTING_SOURCE_FILE: Z:\home\hellas\wine\fs\btrfs\src\volume.c
FAULTING_SOURCE_LINE_NUMBER: 91
FAULTING_SOURCE_CODE:
87:
88: pdo = vde->pdo;
89: IoDeleteDevice(vde->device);
90:
> 91: if (!no_pnp)
92: IoDeleteDevice(pdo);
93: }
94:
95: NTSTATUS vol_close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) {
96: volume_device_extension* vde = DeviceObject->DeviceExtension;
SYMBOL_NAME: btrfs!free_vol+106
MODULE_NAME: btrfs
IMAGE_NAME: btrfs.sys
IMAGE_VERSION: 1.8.2.0
STACK_COMMAND: .cxr; .ecxr ; kb
BUCKET_ID_FUNC_OFFSET: 106
FAILURE_BUCKET_ID: 0xc9_201_btrfs!free_vol
OSPLATFORM_TYPE: x64
OSNAME: Windows 10
FAILURE_ID_HASH: {89d615a5-9eb6-5130-57bc-2f751aed3b9d}
Followup: MachineOwner
---------
I'm new here so this might be wrong but anyway as I happen to have ChatGPT-4 in use, I decided to try give above BSOD analysis and code from problematic feature to it and here what it proposed:
The blue screen error DRIVER_VERIFIER_IOMANAGER_VIOLATION (c9) with the argument A device is deleting itself while there is another device beneath it in the driver stack suggests that there's an issue with how devices are being detached and deleted in the driver stack. The error occurs in the free_vol function of your Btrfs driver, specifically at the point where devices are being deleted.
From the provided code, it seems the issue arises due to the order of operations when deleting device objects (pdo and vde->device). The problem is likely due to the deletion of the vde->device before detaching and deleting the pdo. In the Windows driver model, when you have a chain of device objects, you need to properly detach and delete them in the reverse order of how they were attached.
Here's an updated version of the free_vol function with modifications to fix this issue:
void free_vol(volume_device_extension* vde) {
PDEVICE_OBJECT pdo;
vde->dead = true;
if (vde->mounted_device) {
device_extension* Vcb = vde->mounted_device->DeviceExtension;
Vcb->vde = NULL;
}
if (vde->name.Buffer)
ExFreePool(vde->name.Buffer);
ExDeleteResourceLite(&vde->pdode->child_lock);
// Detach the PDO first if it's attached to any device
if (vde->pdo && vde->pdo->AttachedDevice)
IoDetachDevice(vde->pdo);
// Free other resources
while (!IsListEmpty(&vde->pdode->children)) {
volume_child* vc = CONTAINING_RECORD(RemoveHeadList(&vde->pdode->children), volume_child, list_entry);
if (vc->notification_entry) {
if (fIoUnregisterPlugPlayNotificationEx)
fIoUnregisterPlugPlayNotificationEx(vc->notification_entry);
else
IoUnregisterPlugPlayNotification(vc->notification_entry);
}
if (vc->pnp_name.Buffer)
ExFreePool(vc->pnp_name.Buffer);
ExFreePool(vc);
}
if (no_pnp)
ExFreePool(vde->pdode);
pdo = vde->pdo;
// Delete the vde->device first
if (vde->device)
IoDeleteDevice(vde->device);
// Then delete the pdo
if (!no_pnp && pdo)
IoDeleteDevice(pdo);
}
In this revised version, the code first detaches pdo (if it's attached to any device) before deleting the vde->device. Then, it deletes the pdo. This order ensures that the lower device (pdo) is not prematurely deleted while it's still part of the device stack.