Skip to content

Wayland does hit testing during teardown #16138

Description

@madebr

During SDL_Quit, the wayland video driver might run the hit testing callback.
This callback might not be prepared to run with various destroyed resources and SDL partially shut down.

Reproducer:

  • configure and build SDL3 with -DCMAKE_C_FLAGS="-DSDL_ASSERT_INVALID_PARAMS"
  • run testshape test
  • press escape

(The error does not always happen)

stacktrace:

SDL_ReadSurfacePixel_REAL SDL_surface.c:2813
SDL_ReadSurfacePixel SDL_dynapi_procs.h:738
ShapeHitTest testshape.c:23
pointer_dispatch_absolute_motion SDL_waylandevents.c:674
pointer_handle_frame SDL_waylandevents.c:1287
Wayland_DestroyWindow SDL_waylandwindow.c:3738
SDL_DestroyWindow_REAL SDL_video.c:4587
SDL_VideoQuit SDL_video.c:4699
SDL_QuitSubSystem_REAL SDL.c:671
SDL_Quit_REAL SDL.c:727
SDL_Quit SDL_dynapi_procs.h:725
main testshape.c:145

This can be fixed in testshape by not accessing the surface if it has been destroyed, but that would be the wrong approach imho.

SDL/test/testshape.c

Lines 18 to 30 in 0fb1177

static SDL_HitTestResult SDLCALL ShapeHitTest(SDL_Window *window, const SDL_Point *area, void *userdata)
{
SDL_Surface *shape = (SDL_Surface *)userdata;
Uint8 r, g, b, a;
if (SDL_ReadSurfacePixel(shape, area->x, area->y, &r, &g, &b, &a)) {
if (a != SDL_ALPHA_TRANSPARENT) {
/* We'll just make everything draggable */
return SDL_HITTEST_DRAGGABLE;
}
}
return SDL_HITTEST_NORMAL;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions