Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while clicking on tittle bar #9

Open
SPancerfaustyna opened this issue Mar 11, 2025 · 1 comment
Open

Error while clicking on tittle bar #9

SPancerfaustyna opened this issue Mar 11, 2025 · 1 comment

Comments

@SPancerfaustyna
Copy link

So i was making my first window and i found anoying error while trying to move the window with the mouse. Error is always appearing while trying to click on title bar of the window. I check every example you posted and it also is appearing. On official version this is not present.

Zig version - 0.14.0

D:\ZigProjects\snake\zig-out\bin>snake.exe
thread 13296 panic: left shift of negative value -13
C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\video\windows\SDL_windowsevents.c:1643:0: 0x7ff766e40cd6 in WIN_WindowProc (SDL3.lib)
PostMessage(hwnd, WM_MOUSEMOVE, 0, cursorPos.x | cursorPos.y << 16);

???:?:?: 0x7ffdd85152a0 in ??? (USER32.dll)
???:?:?: 0x7ffdd8512e0c in ??? (USER32.dll)
C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\video\windows\SDL_windowsevents.c:2539:0: 0x7ff766e50d8f in WIN_PumpEvents (SDL3.lib)
DispatchMessage(&msg);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\events\SDL_events.c:1453:0: 0x7ff766c2c099 in SDL_PumpEventsInternal (SDL3.lib)
_this->PumpEvents(_this);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\events\SDL_events.c:1475:0: 0x7ff766c2bfd0 in SDL_PumpEvents_REAL (SDL3.lib)
SDL_PumpEventsInternal(false);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\main\SDL_main_callbacks.c:124:0: 0x7ff7672b062c in SDL_IterateMainCallbacks (SDL3.lib)
SDL_PumpEvents();

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\main\generic\SDL_sysmain_callbacks.c:51:0: 0x7ff766de369f in GenericIterateMainCallbacks (SDL3.lib)
return SDL_IterateMainCallbacks(!iterate_after_waitevent);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\main\generic\SDL_sysmain_callbacks.c:62:0: 0x7ff766de349e in SDL_EnterAppMainCallbacks_REAL (SDL3.lib)
while ((rc = GenericIterateMainCallbacks()) == SDL_APP_CONTINUE) {

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\dynapi\SDL_dynapi_procs.h:207:0: 0x7ff766b4808b in SDL_EnterAppMainCallbacks (SDL3.lib)
SDL_DYNAPI_PROC(int,SDL_EnterAppMainCallbacks,(int a, char *b[], SDL_AppInit_func c, SDL_AppIterate_func d, SDL_AppEvent_func e, SDL_AppQuit_func f),(a,b,c,d,e,f),return)

D:\ZigProjects\snake.zig-cache\o\7b87f4b87ed5fdc3d09a46b59a3d7b20\SDL3\SDL_main_impl.h:59:0: 0x7ff766b41042 in SDL_main (snake.obj)
return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\main\windows\SDL_sysmain_runapp.c:88:0: 0x7ff766e53432 in SDL_RunApp_REAL (SDL3.lib)
result = mainFunction(argc, argv);

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\dynapi\SDL_dynapi_procs.h:804:0: 0x7ff766b8a1a6 in SDL_RunApp_DEFAULT (SDL3.lib)
SDL_DYNAPI_PROC(int,SDL_RunApp,(int a, char *b[], SDL_main_func c, void *d),(a,b,c,d),return)

C:\Users\miern\AppData\Local\zig\p\sdl-0.2.0+3.2.8-7uIn9FxHfQE325TK7b0qpgt10G3x1xl-3ZMOfTzxUg3C\src\dynapi\SDL_dynapi_procs.h:804:0: 0x7ff766b568f1 in SDL_RunApp (SDL3.lib)
SDL_DYNAPI_PROC(int,SDL_RunApp,(int a, char *b[], SDL_main_func c, void *d),(a,b,c,d),return)

D:\ZigProjects\snake.zig-cache\o\7b87f4b87ed5fdc3d09a46b59a3d7b20\SDL3\SDL_main_impl.h:125:0: 0x7ff766b41f86 in WinMain (snake.obj)
return SDL_RunApp(0, NULL, SDL_main, NULL);

C:\Program Files\Zig\zig-windows-x86_64-0.14.0\lib\libc\mingw\crt\crtexewin.c:67:0: 0x7ff766b977a2 in main (mingw32.lib)
return _tWinMain (hInstance, NULL, lpCmdLine, nShowCmd);

C:\Program Files\Zig\zig-windows-x86_64-0.14.0\lib\libc\mingw\crt\crtexe.c:266:0: 0x7ff766b43ddb in __tmainCRTStartup (crt2.obj)
mainret = _tmain (argc, argv, envp);

C:\Program Files\Zig\zig-windows-x86_64-0.14.0\lib\libc\mingw\crt\crtexe.c:186:0: 0x7ff766b43e3b in mainCRTStartup (crt2.obj)
ret = __tmainCRTStartup ();

???:?:?: 0x7ffdd895e8d6 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffdd923bf2b in ??? (ntdll.dll)

@castholm
Copy link
Owner

The crash is due to a bug/undefined behavior in SDL which is caught by Zig enabling UBSan in safety-checked release modes, see #8 for details.

It has already been fixed in the upstream SDL repo (libsdl-org#12505) and will be included here once SDL 3.2.10 is released, which shouldn't take too long.

In the meantime you can either build with ReleaseFast or ReleaseSmall (pass .optimize = ReleaseFast in your build.zig), or use rohlem's fork of this repo which includes the fix: https://github.com/rohlem/SDL/tree/PR-fix-ub-windowsevents-leftshift-negative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants