The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Access violation when calling SDL_CreateTextureFromSurface
LBandy


Joined: 01 Jan 2013
Posts: 38
Hi guys,

We have an application running fine for _most_ of our users. It's been tested on Windows XP, 7, 8, 8.1 and 10. Most of our users can run it fine, but a very few of them experience crashes for all of the time at the same point.

We start up the application, load some files and display them as textures. After pressing a button, we change the text displayed on a one of the gui elements. The issue is either of the following two functions crashes:
- SDL_CreateTextureFromSurface
- SDL_ConvertSurface

We have a ResourceManager object which manages all the SDL calls, and works fine for all the program for most of our users, but it looks like to be causing issues on a few of them. We are correctly guarding against NULL pointers, etc...

The question is, under what circumstances these calls can crash in an access violation?

Attached some info from windbg:

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 009f7bf1 (program!SDL_CreateTextureFromSurface+0x00000051)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000019
Attempt to read from address 00000019

DEFAULT_BUCKET_ID: NULL_CLASS_PTR_READ
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
BUGCHECK_STR: APPLICATION_FAULT_NULL_CLASS_PTR_READ

Thank you for your answers!
Access violation when calling SDL_CreateTextureFromSurface
Gabriele Greco
Guest

Quote:

The question is, under what circumstances these calls can crash in an access violation?

Attached some info from windbg:

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 009f7bf1 (program!SDL_CreateTextureFromSurface+0x00000051)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000019
Attempt to read from address 00000019

DEFAULT_BUCKET_ID: NULL_CLASS_PTR_READ
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
BUGCHECK_STR: APPLICATION_FAULT_NULL_CLASS_PTR_READ






Your DBG output seems to show that you are indeed passing a null pointer as first parameter and a null pointer with some bytes of offset (maybe a struct member?) as second parameter, so indeed the problem is with null pointers.



Maybe it happens only on some systems for synchronization issues?