[Bug]: AMF Encoder is crashing when used from Windows Service
Describe the bug Starting with version 23.2.1 of AMD drivers the SDK crashes when AMF Video Encoder Init method is called from a service.
Module that fails: amfrtdrv32.dll Module base address: 0x53220000 Failed address: 0x5324d0f8()
Exception thrown at 0x5324D0F8 (amfrtdrv32.dll) in XXX.exe: 0xC0000005: Access violation reading location 0x00000000.
As far as I can tell you are not handling properly the return from IDXGIAdapter::EnumOutputs which is DXGI_ERROR_NOT_CURRENTLY_AVAILABLE when in service mode.
To Reproduce Try to initialize AMF Encoder from a Windows service. It will crash with access violation in the Init method.
Reproducing here also, killing our product for any of our customers on AMD with this driver.
OS: Server 2019 GPU: RX6600 amfrtdrv32.dll file version: 31.0.1.14043.7000 (tested Catalyst 23.2.1 and 23.4.1)
Also reproducing with: OS: Server 2019 GPU: V620 amfrtdrv64.dll file version: 31.0.14043.7000
ExceptionAddress: 00007ffd163639d2 (amfrtdrv64+0x00000000000339d2)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 0000000000000000
Attempt to read from address 0000000000000000
PROCESS_NAME: program.exe
READ_ADDRESS: 0000000000000000
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.
EXCEPTION_CODE_STR: c0000005
EXCEPTION_PARAMETER1: 0000000000000000
EXCEPTION_PARAMETER2: 0000000000000000
STACK_TEXT:
000000ab`c8d0e840 00007ffd`163dc209 : 000001d4`ffdc9500 00007ffd`16a1f110 000001d4`fefc6530 ffffffff`ffffffff : amfrtdrv64+0x339d2
000000ab`c8d0eb70 00007ffd`163c2b6b : 00000000`00000030 00000000`00000000 000001d4`ffda4970 000000ab`c8d0ed79 : amfrtdrv64+0xac209
000000ab`c8d0ecc0 00007ffd`163c0c8e : 000001d4`ffda4970 00000000`00000058 000001d4`ffda4970 00007ffd`16adc050 : amfrtdrv64+0x92b6b
000000ab`c8d0ee70 00007ff6`349f485c : 000000ab`c8d0f180 000001d4`fe325b18 000001d4`fe325af0 000001d4`00001000 : amfrtdrv64+0x90c8e
000000ab`c8d0f150 00007ff6`349eb138 : 00000000`00000008 00007ff6`3527e7f0 00000000`00000002 00000000`00000045 : program!AMFH264_CreateEncodeContext+0x30c
000000ab`c8d0f210 00007ff6`3498ef0f : 00007ff6`3521f190 00000000`ffffffff 00007ff6`3527e7f0 00000000`00000002 : program!Func2+0x1c8
000000ab`c8d0f410 00007ff6`3498ecea : 00007ff6`3527e7f0 00007ff6`350f1820 00007ff6`3527e7f0 00000000`00000001 : program!Func1+0x12f
000000ab`c8d0fce0 00007ff6`34fb55fa : 00000000`0000000a 00000000`00000000 00000000`00000000 00000000`00000000 : program!WinMain+0x14a
000000ab`c8d0fd10 00007ffd`4b1e7ac4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : program!__scrt_common_main_seh+0x106
000000ab`c8d0fd50 00007ffd`4cd2a351 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14
000000ab`c8d0fd80 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21
STACK_COMMAND: ~0s; .ecxr ; kb
SYMBOL_NAME: amfrtdrv64+339d2
MODULE_NAME: amfrtdrv64
IMAGE_NAME: amfrtdrv64.dll
FAILURE_BUCKET_ID: NULL_POINTER_READ_c0000005_amfrtdrv64.dll!Unknown
OS_VERSION: 10.0.17763.1
BUILDLAB_STR: rs5_release
OSPLATFORM_TYPE: x64
OSNAME: Windows 10
IMAGE_VERSION: 31.0.14043.7000
FAILURE_ID_HASH: {153c7bb9-ca44-bd9b-bc97-30e0e44b7855}
Also reproducing with Catalyst 22.12.1 and V620, Server 2019.
Thanks for catching and reporting this issue. We fixed it and it will be available in a subsequent public driver release.