| Summary: | SDL_BlitScaled causes access violation in some cases. Possible error in rect calculation. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Simon Hug <chli.hug> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Testcase for a scaled blit that causes an access violation.
patch test case |
||
|
Description
Simon Hug
2016-05-20 19:06:24 UTC
Created attachment 2600 [details]
patch
I think this patch fix the issue, but maybe it's worth re-writing "SDL_UpperBlitScaled" using SDL_FRect.
Simon, can you verify that this fixes your crash and works correctly? Thanks! Yes, that fixes it. Seems to work correctly. It looks like the rounding of the width also had the same issue. I didn't notice it before, but my testing showed that certain SDL_Rect values could cause wrong rounding, the scaler would overread and use the first pixel of the next row. All fixed with that patch. Thanks! Hello, I am just noticing I still have the diff in my repos. So this means nothing has been merged for this ticket. Is this getting lost or does it need more testing? I think your patch is no longer necessary. I believe the bug was fixed by another patch. Created attachment 2641 [details]
test case
I just re-tested it with the latest trunk and this still exists: this is detected by valgrind as an invalid read:
==17367== Invalid read of size 4
==17367== at 0x4F3C0D7: SDL_Blit_Slow (SDL_blit_slow.c:77)
==17367== by 0x4EF2734: SDL_SoftBlit (SDL_blit.c:88)
==17367== by 0x4F48767: SDL_LowerBlit_REAL (SDL_surface.c:553)
==17367== by 0x4F4931C: SDL_LowerBlitScaled_REAL (SDL_surface.c:830)
==17367== by 0x4F491DC: SDL_UpperBlitScaled_REAL (SDL_surface.c:803)
==17367== by 0x4E7727B: SDL_UpperBlitScaled (SDL_dynapi_procs.h:505)
==17367== by 0x108A1D: main (bug_3340_blitscaled.c:24)
==17367== Address 0x9c36000 is 0 bytes after a block of size 1,920,000 alloc'd
==17367== at 0x4C2CB3F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17367== by 0x4EE6634: SDL_malloc_REAL (SDL_malloc.c:36)
==17367== by 0x4F479B5: SDL_CreateRGBSurfaceWithFormat_REAL (SDL_surface.c:83)
==17367== by 0x4F47E4E: SDL_CreateRGBSurface_REAL (SDL_surface.c:127)
==17367== by 0x4E76B56: SDL_CreateRGBSurface (SDL_dynapi_procs.h:478)
==17367== by 0x1089A9: main (bug_3340_blitscaled.c:12)
I attached my testcase!
Marked as reopened Fixed, thanks! https://hg.libsdl.org/SDL/rev/1889c850fafc for the record: https://hg.libsdl.org/SDL/rev/7101c5a0d561 - better fix to clip after scaling computation is done, it was still crash in some case - add back back SDL_round (removed in bug #2687, added in bug #5404) |