Description
Running pygame.tests.surface_test
under AddressSanitizer reports an illegal overlapping memcpy()
in scroll_default()
which was introduced in #2855. It seems like some of the new memcpy()
invocations introduced there need to be changed to memmove()
like the old implementation had.
=================================================================
==172097==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x515000412b20,0x515000412b32) and [0x515000412b22, 0x515000412b34) overlap
#0 0x72eac26fad46 in memcpy /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115
#1 0x72eabf39f9d2 in scroll_default ../src_c/surface.c:2522
#2 0x72eabf39f9d2 in scroll ../src_c/surface.c:2554
#3 0x72eabf39f9d2 in surf_scroll ../src_c/surface.c:2635
#4 0x72eac2197c97 (/usr/lib/libpython3.13.so.1.0+0x197c97) (BuildId: 31a24ec0805217755810c6e20886eb3260a0a6d3)
#5 0x72eac215f82c in PyObject_Vectorcall (/usr/lib/libpython3.13.so.1.0+0x15f82c) (BuildId: 31a24ec0805217755810c6e20886eb3260a0a6d3)
#6 0x72eac216f306 in _PyEval_EvalFrameDefault (/usr/lib/libpython3.13.so.1.0+0x16f306) (BuildId: 31a24ec0805217755810c6e20886eb3260a0a6d3)
[snip]
0x515000412b20 is located 32 bytes inside of 456-byte region [0x515000412b00,0x515000412cc8)
allocated by thread T0 here:
#0 0x72eac26fd721 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x72eabb50c636 in real_malloc /home/cgutman/SDL/src/stdlib/SDL_malloc.c:6327
#2 0x72eabb50cae8 in SDL_malloc_REAL /home/cgutman/SDL/src/stdlib/SDL_malloc.c:6452
#3 0x72eabb5155ea in SDL_aligned_alloc_REAL /home/cgutman/SDL/src/stdlib/SDL_stdlib.c:546
#4 0x72eabb86f2f9 in SDL_CreateSurface_REAL /home/cgutman/SDL/src/video/SDL_surface.c:229
#5 0x72eabb0d799c in SDL_CreateSurface /home/cgutman/SDL/src/dynapi/SDL_dynapi_procs.h:153
#6 0x72eabe2e6656 in SDL_CreateRGBSurfaceWithFormat_REAL /home/cgutman/sdl2-compat/src/sdl2_compat.c:4277
#7 0x72eabe3388f0 in SDL_CreateRGBSurfaceWithFormat /home/cgutman/sdl2-compat/src/dynapi/SDL_dynapi_procs.h:631
#8 0x72eabf3a1877 in surface_init ../src_c/surface.c:670
#9 0x72eac216ecd3 in _PyEval_EvalFrameDefault (/usr/lib/libpython3.13.so.1.0+0x16ecd3) (BuildId: 31a24ec0805217755810c6e20886eb3260a0a6d3)
[snip]
0x515000412b22 is located 34 bytes inside of 456-byte region [0x515000412b00,0x515000412cc8)
allocated by thread T0 here:
#0 0x72eac26fd721 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x72eabb50c636 in real_malloc /home/cgutman/SDL/src/stdlib/SDL_malloc.c:6327
#2 0x72eabb50cae8 in SDL_malloc_REAL /home/cgutman/SDL/src/stdlib/SDL_malloc.c:6452
#3 0x72eabb5155ea in SDL_aligned_alloc_REAL /home/cgutman/SDL/src/stdlib/SDL_stdlib.c:546
#4 0x72eabb86f2f9 in SDL_CreateSurface_REAL /home/cgutman/SDL/src/video/SDL_surface.c:229
#5 0x72eabb0d799c in SDL_CreateSurface /home/cgutman/SDL/src/dynapi/SDL_dynapi_procs.h:153
#6 0x72eabe2e6656 in SDL_CreateRGBSurfaceWithFormat_REAL /home/cgutman/sdl2-compat/src/sdl2_compat.c:4277
#7 0x72eabe3388f0 in SDL_CreateRGBSurfaceWithFormat /home/cgutman/sdl2-compat/src/dynapi/SDL_dynapi_procs.h:631
#8 0x72eabf3a1877 in surface_init ../src_c/surface.c:670
#9 0x72eac216ecd3 in _PyEval_EvalFrameDefault (/usr/lib/libpython3.13.so.1.0+0x16ecd3) (BuildId: 31a24ec0805217755810c6e20886eb3260a0a6d3)
[snip]
SUMMARY: AddressSanitizer: memcpy-param-overlap /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115 in memcpy
==172097==ABORTING
Environment:
pygame-ce commit: 0510571
pygame-ce 2.5.4.dev1 (SDL 2.32.55, Python 3.13.3)
Platform: Linux-6.14.3-arch1-1-x86_64-with-glibc2.41
System: Linux
System Version: #1 SMP PREEMPT_DYNAMIC Sun, 20 Apr 2025 12:38:52 +0000
Processor: SSE2: Yes AVX2: No NEON: No
Architecture: Bits: 64bit Linkage: ELF
Python: CPython 3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]
GIL Enabled: True
pygame version: 2.5.4.dev1
SDL versions: Linked: 2.32.55 Compiled: 2.32.55
SDL Mixer versions: Linked: 2.8.1 Compiled: 2.8.1
SDL Font versions: Linked: 2.24.0 Compiled: 2.24.0
SDL Image versions: Linked: 2.8.8 Compiled: 2.8.8
Freetype versions: Linked: 2.13.3 Compiled: 2.13.3
Display Driver: Display Not Initialized
Mixer Driver: Mixer Not Initialized
Metadata
Metadata
Assignees
Labels
No labels