Giter Club home page Giter Club logo

Comments (5)

slouken avatar slouken commented on September 13, 2024

Are you calling SDL_Quit()? It looks like that message is set using SDL_SetError()

from sdl.

0xc0de avatar 0xc0de commented on September 13, 2024

Are you calling SDL_Quit()? It looks like that message is set using SDL_SetError()

Yes, I'm calling SDL_Quit. I can give the entire sequence of SDL function calls, which may help in finding the problem.

from sdl.

slouken avatar slouken commented on September 13, 2024

Yeah, a simple example would help, along with your build and runtime environment.

from sdl.

0xc0de avatar 0xc0de commented on September 13, 2024

Hello! I was able to cut out all the code and leave only a small set of calls that can reproduce the bug.

Interestingly, the bug is not always reproduced, so I inserted β€œSleep” into the code to make a slight delay, as if a heavy application was loading.

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

    SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_SENSOR | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_EVENTS);

    Sleep(10000);

    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
        case SDL_EVENT_GAMEPAD_ADDED: {
            SDL_Gamepad* gamepad = SDL_OpenGamepad(event.gdevice.which);
            OutputDebugStringA(SDL_GetGamepadName(gamepad));
            OutputDebugStringA("\n");
            break;
        }
        }
    }
    SDL_Quit();
    return 0;
}
Output:
onecoreuap\xbox\devices\api\winrt\pnpdevice.cpp(507)\Windows.Gaming.Input.dll!00007FFD43438136: (caller: 00007FFD4343B8CB) ReturnHr(1) tid(81a0) 80070005 Access is denied.
Xbox One Controller
Detected memory leaks!
Dumping objects ->
{3452} normal block at 0x000001F07AE49430, 120 bytes long.
 Data: <`k4}            > 60 6B 34 7D F0 01 00 00 00 00 00 00 00 00 00 00 
{3419} normal block at 0x000001F07AE5C4F0, 36 bytes long.
 Data: <No HID devices f> 4E 6F 20 48 49 44 20 64 65 76 69 63 65 73 20 66 
{3418} normal block at 0x000001F07AE52A40, 72 bytes long.
 Data: <         z z    > 04 00 00 00 CD CD CD CD A0 7A E4 7A F0 01 00 00 
{3417} normal block at 0x000001F07AE47AA0, 40 bytes long.
 Data: <           z    > 01 00 00 00 00 00 00 00 F0 C4 E5 7A F0 01 00 00 
Object dump complete.

SDL Cmake output:
Checking for module 'libusb-1.0>=1.0.16'
  Package 'libusb-1.0', required by 'virtual:world', not found
Could NOT find LibUSB (missing: LibUSB_LIBRARY LibUSB_INCLUDE_PATH) (found version "LibUSB_VERSION-NOTFOUND")

SDL3 was configured with the following options:

Platform: Windows-10.0.19045
64-bit:   TRUE
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Revision: SDL-2215c245
Vendor:   

Subsystems:
  Audio:    ON
  Video:    ON
  Render:   OFF
  Camera:   ON
  Joystick: ON
  Haptic:   ON
  Hidapi:   ON
  Power:    ON
  Sensor:   ON
  Dialog:   ON

Options:
  SDL_ALSA                    (Wanted: OFF): OFF
  SDL_ALSA_SHARED             (Wanted: OFF): OFF
  SDL_ALTIVEC                 (Wanted: OFF): OFF
  SDL_ARMNEON                 (Wanted: OFF): OFF
  SDL_ARMSIMD                 (Wanted: OFF): OFF
  SDL_ASAN                    (Wanted: OFF): OFF
  SDL_ASSEMBLY                (Wanted: ON): ON
  SDL_ASSERTIONS              (Wanted: auto): auto
  SDL_AVX                     (Wanted: ON): ON
  SDL_AVX2                    (Wanted: ON): ON
  SDL_AVX512F                 (Wanted: ON): ON
  SDL_BACKGROUNDING_SIGNAL    (Wanted: OFF): OFF
  SDL_CCACHE                  (Wanted: OFF): OFF
  SDL_CLANG_TIDY              (Wanted: OFF): OFF
  SDL_CLOCK_GETTIME           (Wanted: OFF): OFF
  SDL_COCOA                   (Wanted: OFF): OFF
  SDL_DBUS                    (Wanted: OFF): OFF
  SDL_DIRECTX                 (Wanted: OFF): OFF
  SDL_DISABLE_INSTALL         (Wanted: ON): OFF
  SDL_DISABLE_UNINSTALL       (Wanted: OFF): OFF
  SDL_DISKAUDIO               (Wanted: ON): ON
  SDL_DUMMYAUDIO              (Wanted: ON): ON
  SDL_DUMMYCAMERA             (Wanted: ON): ON
  SDL_DUMMYVIDEO              (Wanted: ON): ON
  SDL_EXAMPLES                (Wanted: OFF): OFF
  SDL_EXAMPLES_LINK_SHARED    (Wanted: OFF): OFF
  SDL_FOREGROUNDING_SIGNAL    (Wanted: OFF): OFF
  SDL_GCC_ATOMICS             (Wanted: OFF): OFF
  SDL_HIDAPI                  (Wanted: ON): ON
  SDL_HIDAPI_JOYSTICK         (Wanted: ON): ON
  SDL_HIDAPI_LIBUSB           (Wanted: ON): OFF
  SDL_HIDAPI_LIBUSB_SHARED    (Wanted: ON): OFF
  SDL_IBUS                    (Wanted: OFF): OFF
  SDL_INSTALL_TESTS           (Wanted: OFF): OFF
  SDL_JACK                    (Wanted: OFF): OFF
  SDL_JACK_SHARED             (Wanted: OFF): OFF
  SDL_KMSDRM                  (Wanted: OFF): OFF
  SDL_KMSDRM_SHARED           (Wanted: OFF): OFF
  SDL_LASX                    (Wanted: OFF): OFF
  SDL_LIBC                    (Wanted: ON): ON
  SDL_LIBICONV                (Wanted: OFF): OFF
  SDL_LIBUDEV                 (Wanted: ON): OFF
  SDL_LSX                     (Wanted: OFF): OFF
  SDL_METAL                   (Wanted: OFF): OFF
  SDL_MMX                     (Wanted: ON): OFF
  SDL_OFFSCREEN               (Wanted: ON): ON
  SDL_OPENGL                  (Wanted: ON): ON
  SDL_OPENGLES                (Wanted: ON): ON
  SDL_OSS                     (Wanted: OFF): OFF
  SDL_PIPEWIRE                (Wanted: OFF): OFF
  SDL_PIPEWIRE_SHARED         (Wanted: OFF): OFF
  SDL_PTHREADS                (Wanted: OFF): OFF
  SDL_PTHREADS_SEM            (Wanted: OFF): OFF
  SDL_PULSEAUDIO              (Wanted: OFF): OFF
  SDL_PULSEAUDIO_SHARED       (Wanted: OFF): OFF
  SDL_RENDER_D3D              (Wanted: OFF): OFF
  SDL_RENDER_D3D11            (Wanted: OFF): OFF
  SDL_RENDER_D3D12            (Wanted: OFF): OFF
  SDL_RENDER_METAL            (Wanted: OFF): OFF
  SDL_RENDER_VULKAN           (Wanted: OFF): OFF
  SDL_ROCKCHIP                (Wanted: OFF): OFF
  SDL_RPATH                   (Wanted: OFF): OFF
  SDL_RPI                     (Wanted: OFF): OFF
  SDL_SNDIO                   (Wanted: OFF): OFF
  SDL_SNDIO_SHARED            (Wanted: OFF): OFF
  SDL_SSE                     (Wanted: ON): ON
  SDL_SSE2                    (Wanted: ON): ON
  SDL_SSE3                    (Wanted: ON): ON
  SDL_SSE4_1                  (Wanted: ON): ON
  SDL_SSE4_2                  (Wanted: ON): ON
  SDL_SYSTEM_ICONV            (Wanted: OFF): OFF
  SDL_TESTS                   (Wanted: OFF): OFF
  SDL_TESTS_LINK_SHARED       (Wanted: OFF): OFF
  SDL_VIRTUAL_JOYSTICK        (Wanted: ON): ON
  SDL_VIVANTE                 (Wanted: OFF): OFF
  SDL_VULKAN                  (Wanted: ON): ON
  SDL_WASAPI                  (Wanted: ON): ON
  SDL_WAYLAND                 (Wanted: OFF): OFF
  SDL_WAYLAND_LIBDECOR        (Wanted: OFF): OFF
  SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
  SDL_WAYLAND_SHARED          (Wanted: OFF): OFF
  SDL_X11                     (Wanted: OFF): OFF
  SDL_X11_SHARED              (Wanted: OFF): OFF
  SDL_X11_XCURSOR             (Wanted: OFF): OFF
  SDL_X11_XDBE                (Wanted: OFF): OFF
  SDL_X11_XFIXES              (Wanted: OFF): OFF
  SDL_X11_XINPUT              (Wanted: OFF): OFF
  SDL_X11_XRANDR              (Wanted: OFF): OFF
  SDL_X11_XSCRNSAVER          (Wanted: OFF): OFF
  SDL_X11_XSHAPE              (Wanted: OFF): OFF
  SDL_XINPUT                  (Wanted: ON): ON

 Build Shared Library: OFF
 Build Static Library: ON
 Build Static Library with Position Independent Code: 

from sdl.

slouken avatar slouken commented on September 13, 2024

Ah, okay. This is an allocation from a Windows internal worker thread, which doesn't provide us any way to clean up. This isn't a leak we can fix, unfortunately.

Here's an SDL3 style version of the test program:

#include <SDL3/SDL.h>
#include <SDL3/SDL_test_memory.h>

int main(int argc, char *argv[])
{
    SDLTest_TrackAllocations();
    SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_SENSOR | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_EVENTS);

    SDL_Delay(10000);

    SDL_Event event;
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
        case SDL_EVENT_GAMEPAD_ADDED:
        {
            SDL_Gamepad *gamepad = SDL_OpenGamepad(event.gdevice.which);
            SDL_Log(SDL_GetGamepadName(gamepad));
            SDL_CloseGamepad(gamepad);
            break;
        }
        }
    }
    SDL_Quit();
    SDLTest_LogAllocations();
    return 0;
}

And here's the callstack for the allocation:

>	SDL3.dll!register_string_error_to_buffer(wchar_t * * error_buffer, const wchar_t * string_error) Line 355	C
 	SDL3.dll!register_global_error(const wchar_t * string_error) Line 390	C
 	SDL3.dll!PLATFORM_hid_enumerate(unsigned short vendor_id, unsigned short product_id) Line 1079	C
 	SDL3.dll!SDL_hid_enumerate_REAL(unsigned short vendor_id, unsigned short product_id) Line 1438	C
 	SDL3.dll!HIDAPI_UpdateDeviceList() Line 1152	C
 	SDL3.dll!HIDAPI_IsDevicePresent(unsigned short vendor_id, unsigned short product_id, unsigned short version, const char * name) Line 1303	C
 	SDL3.dll!SDL_JoystickHandledByAnotherDriver(SDL_JoystickDriver * driver, unsigned short vendor_id, unsigned short product_id, unsigned short version, const char * name) Line 688	C
 	SDL3.dll!IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable * sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController * e) Line 450	C
 	Windows.Gaming.Input.dll!Microsoft::WRL::Details::DelegateArgTraits<long ( Windows::Foundation::IEventHandler_impl<struct Windows::Foundation::Internal::AggregateType<class Windows::Gaming::Input::RawGameController *,struct Windows::Gaming::Input::IRawGameController *> >::*)(struct IInspectable *,struct Windows::Gaming::Input::IRawGameController *)>::DelegateInvokeHelper<struct Microsoft::WRL::Implements<struct Microsoft::WRL::RuntimeClassFlags<2>,struct Windows::Foundation::IEventHandler<class Windows::Gaming::Input::RawGameController *>,class Microsoft::WRL::FtmBase>,class <lambda_6da117dbca11818c9940be4048cacede>,-1,struct IInspectable *,struct Windows::Gaming::Input::IRawGameController *>::Invoke(struct IInspectable *,struct Windows::Gaming::Input::IRawGameController *)	Unknown
 	Windows.Gaming.Input.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<class <lambda_3e8a25caeb091c28731e50f5efe4ea5a>,struct Windows::Foundation::IEventHandler<class Windows::Gaming::Input::FlightStick *> >(class <lambda_3e8a25caeb091c28731e50f5efe4ea5a>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::Gaming::Input::FlightStick *>,struct Microsoft::WRL::InvokeModeOptions<-2> > *)	Unknown
 	Windows.Gaming.Input.dll!Windows::Gaming::Input::Custom::Details::CustomGameControllerFactoryBase<class Windows::Gaming::Input::RawGameController,class Windows::Gaming::Input::RawGameController,struct Windows::Gaming::Input::IRawGameController,struct Windows::Gaming::Input::IRawGameControllerStatics,class Microsoft::WRL::Details::Nil>::UpdateGameControllerCollection(struct Windows::Gaming::Input::IGameController *,bool)	Unknown
 	Windows.Gaming.Input.dll!FactoryManager::SendControllerNotifications(void)	Unknown
 	SHCore.dll!WorkThreadManager::CThread::RunCurrentTaskUnderLock(void)	Unknown
 	SHCore.dll!WorkThreadManager::CThread::ThreadProc(void)	Unknown
 	SHCore.dll!<lambda_9844335fc14345151eefcc3593dd6895>::<lambda_invoker_cdecl>(void *)	Unknown
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown

from sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.