We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4017 - Memory access violation when rendering specific src/dest texture flipped (Software Rendering).
Summary: Memory access violation when rendering specific src/dest texture flipped (Sof...
Status: RESOLVED INVALID
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.1
Hardware: x86 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-30 19:17 UTC by Jan
Modified: 2018-01-29 09:14 UTC (History)
1 user (show)

See Also:


Attachments
test case (4.46 KB, text/x-csrc)
2018-01-29 09:13 UTC, Sylvain
Details
an image (134.37 KB, image/bmp)
2018-01-29 09:13 UTC, Sylvain
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2017-12-30 19:17:41 UTC
Version is 2.0.2 (Not listed under versions).

How to reproduce:
1. Set the SDL_Renderer to SDL_RENDERER_SOFTWARE.
2. Load a png to surface, then call SDL_CreateTextureFromSurface() to create the 
   texture.
3. Render the texture on the screen, and set the source destination to:
   x = 0;
   y = 0;
   w = sub-texture-width.
   h = texture-height.
4. Flip the texture horizontally, leaving the center point NULL.
5. Leave the destination width and height the same as the source width and height.

This will result in either a crash or a distorted texture:

https://i.gyazo.com/7a80f090c41afaf0068f2450c3e2512e.mp4

It doesn't seem to affect all textures. The snail hide animation only has 3 frames and works fine,
while the move animation (4 frames) seems to created the distorted texture.

With hardware rendering enabled, the animation looks just fine:
https://i.gyazo.com/3f1187ffd22c491ea1753732af627ce4.mp4

When I set the player character texture to render at it's native resolution, and loaded an image with 4 frames, the entire program crashed; giving me an access violation error.

The distortion only occurs when the texture is flipped and when the destination width and height match the original image's width and height (The sub-frame dimensions that is).
At first I thought I made a mistake somewhere (Since I'm pretty new to SDL), but since hardware rendering works fine I don't believe this to be the case.

I hope that this is helpful, and that I provided enough information for the issue to be tracked. I can provide the source if necessary.
Comment 1 Sylvain 2018-01-02 14:48:42 UTC
Probably fixed in latest SDL version. Can  you try it ? 
if this still happens, can you submit a testcase.
Comment 2 Sylvain 2018-01-29 09:13:29 UTC
Created attachment 3154 [details]
test case

A test case
Comment 3 Sylvain 2018-01-29 09:13:50 UTC
Created attachment 3155 [details]
an image

an image
Comment 4 Sylvain 2018-01-29 09:14:36 UTC
A test case to see the issue. this has been fixed between 2.0.5 and 2.0.6