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 2677

Summary: SDL_UpdateTexture crashes for texture with SDL_TEXTUREACCESS_TARGET
Product: SDL Reporter: Damian Kaczmarek <rush>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.0   
Hardware: x86   
OS: Windows (All)   
Attachments: Example showing the problem
Fix for the bug

Description Damian Kaczmarek 2014-08-08 14:54:28 UTC
Created attachment 1806 [details]
Example showing the problem

I have SDL2 compiled from latest HG with mingw.

i686-w64-mingw32-g++ sdl2_windows-sdl_update_texture_crash.cpp -l SDL2 -o sdl2_windows-sdl_update_texture_crash.exe

Crashes both on Windows and on Wine. Example works on Linux.

Crashes inside SDL_UpdateTexture

Please advise

Note: possibly duplicate of Bug 2625 but not sure
Comment 1 Damian Kaczmarek 2014-08-08 16:56:30 UTC
Created attachment 1807 [details]
Fix for the bug

Fixed crash, please review. According to my tests it's working properly.
Comment 2 Sam Lantinga 2014-08-17 05:54:38 UTC
According to the documentation, the lockrect on the render target, created in D3DPOOL_DEFAULT, should fail:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb205913(v=vs.85).aspx

Is that what you're seeing? The update doesn't crash, but also doesn't actually happen?
Comment 3 Sam Lantinga 2014-08-17 06:18:33 UTC
Can you check to see if this fixes the issue for you?
https://hg.libsdl.org/SDL/rev/86a6f6d92960

Thanks!
Comment 4 Damian Kaczmarek 2014-08-17 12:24:53 UTC
As far as I am concerned my update fixed it and I am not seeing any adverse effects. In what way is it wrong? Do you have a test program that fails? I see your patch is quite large. I can check this but probably tomorrow earliest.
Comment 5 Sam Lantinga 2014-08-17 17:13:02 UTC
LockRect on the render target, created in D3DPOOL_DEFAULT is supposed to fail, according to Microsoft's documentation, and I have seen this in the past. My patch uses a staging surface for render targets as well, which is the recommended way of updating textures.
Comment 6 Damian Kaczmarek 2014-08-17 22:31:36 UTC
I see, so it worked for me by accident? :) (non conformant NVIDIA driver?)
Comment 7 Sam Lantinga 2014-08-17 23:33:51 UTC
Yes, most likely. When you get a chance, can you try the patch?

Thanks!
Comment 8 Ryan C. Gordon 2015-02-19 02:54:48 UTC
Just pinging to see if we can close this bug with the changes Sam made, or if it needs further work.

--ryan.
Comment 9 Ryan C. Gordon 2015-02-19 02:55:48 UTC
Whoops, changing the bug status back to WAITING

--ryan.
Comment 10 Ryan C. Gordon 2015-05-31 05:57:12 UTC
Marking this as a duplicate of Bug #2625, under the assumption that it's the same problem and benefits from the same fix. Please feel free to reopen if this is still causing you problems!

--ryan.

*** This bug has been marked as a duplicate of bug 2625 ***