Repository navigation
Description
Describe the bug
I encountered a native Windows crash during normal live playback with FVP 0.38.1. The application exits with a null read inside fvp.dll on Flutter's raster thread.
WER / WinDbg details:
- exception:
0xc0000005(read from address0x0) - faulting module:
fvp.dll0.38.1.0 - fault offset:
fvp.dll+0xd34a RCX = 0- faulting instruction:
mov rax, qword ptr [rcx] - Flutter 3.41.9
- Windows x64
- mdk 0.38.0, build 4540373
The relevant disassembly maps exactly to the Windows GPU surface descriptor callback:
mov rdx, [rbx+8]
mov rcx, [rdx+788h] ; ctx (null)
mov r8, [rdx+780h] ; rt
mov rdx, [rdx+778h] ; tex
mov rax, [rcx] ; crash
call [rax+178h] ; ID3D11DeviceContext::CopyResource
mov rax, [rbx+8]
mov rcx, [rax+788h]
mov rax, [rcx]
call [rax+378h] ; ID3D11DeviceContext::FlushThis matches:
ctx->CopyResource(tex.Get(), rt.Get());
ctx->Flush();I think there is a lifetime race in ReleaseRT. Flutter documents TextureRegistrar::UnregisterTexture as asynchronous, but the current code uses the deprecated overload and immediately erases the last stored shared_ptr<TexturePlayer>:
texture_registrar_->UnregisterTexture(texId);
players_.erase(it);The raster thread may therefore still enter the descriptor callback, which captures this, after the TexturePlayer and its D3D COM members have started being destroyed.
I prepared this local change, which compiles successfully in Windows Release builds:
if (auto it = players_.find(texId); it != players_.cend()) {
auto player = it->second;
texture_registrar_->UnregisterTexture(texId, [player]() {});
players_.erase(it);
} else {
texture_registrar_->UnregisterTexture(texId, []() {});
}I also added a defensive null check before CopyResource, although keeping the callback owner alive until unregistration completes appears to be the actual fix.
Expected behavior
Releasing or replacing a Windows texture should not allow Flutter's raster thread to call a descriptor callback after its owner has been destroyed.
Would you agree with using the asynchronous completion callback to retain TexturePlayer? I can prepare a PR if useful.
I can provide additional sanitized WinDbg output if needed, but I have not attached the user minidump.
Thanks
Activity
wang-bin commentedon Sep 17, 2026
agree, player should be destroyed after texture is actually removed. patch is welcome