SDL 1.2.13: Probable bug in BlitMap handling

Hello,

I am having a bug with the SDL version currently shipping with the
latest Ubuntu (SDL 1.2.13).
Not sure if this has been fixed in 1.2.14, but the changelog suggests
this hasn’t changed.

What I am doing looks like:

SDL_Surface *A is an image
SDL_Surface *buf is an offscreen buffer
SDL_Surface *disp is the display surface

// Blit A to my offscreen buffer
SDL_BlitSurface(A, NULL, buf, someRect);
-> under the hood SDL sets A->map->dst to buf and optimizes A with
RLE encoding

// Do some uninterresting things with buf

// Release buf
SDL_FreeSurface(buf);

// Lock A
SDL_LockSurface(A);
// Do some stuff at the pixel level on A

// Unlock A
SDL_Unlock(A);

The program crashes there, in RLEAlphaSurface (SDL_RLEaccel.c),
because A->map->dest still points to buf, which has been released, and
SDL tries to read some of its data.

I am aware that my sequence of SDL functions may seem a bit odd, but I
don’t think I am doing anything illegal.
It seems that there is some code missing in SDL_FreeSurface() to undo
the SDL_MapSurfaces() that get done under the hood, isn’t it?

Florent Boudet

Yeah, that sounds like a legitimate bug. Can you submit a bug report
and minimal test case to http://bugzilla.libsdl.org ?

Thanks!On Mon, Dec 21, 2009 at 2:41 PM, florent boudet wrote:

Hello,

I am having a bug with the SDL version currently shipping with the
latest Ubuntu (SDL 1.2.13).
Not sure if this has been fixed in 1.2.14, but the changelog suggests
this hasn’t changed.

What I am doing looks like:

SDL_Surface *A is an image
SDL_Surface *buf is an offscreen buffer
SDL_Surface *disp is the display surface

// Blit A to my offscreen buffer
SDL_BlitSurface(A, NULL, buf, someRect);
?-> under the hood SDL sets A->map->dst to buf and optimizes A with
RLE encoding

// Do some uninterresting things with buf

// Release buf
SDL_FreeSurface(buf);

// Lock A
SDL_LockSurface(A);
// Do some stuff at the pixel level on A

// Unlock A
SDL_Unlock(A);

The program crashes there, in RLEAlphaSurface (SDL_RLEaccel.c),
because A->map->dest still points to buf, which has been released, and
SDL tries to read some of its data.

I am aware that my sequence of SDL functions may seem a bit odd, but I
don’t think I am doing anything illegal.
It seems that there is some code missing in SDL_FreeSurface() to undo
the SDL_MapSurfaces() that get done under the hood, isn’t it?

Florent Boudet


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I am trying to get my game working with the new 1.3 API, and have the
following two issues:

Code snippet:

SDL_Surface *pSurface = IMG_Load( “background.tga” );

SDL_Surface *pNewSurface = SDL_DisplayFormat( pSurface ); // ISSUE 1:
NewSurface is NULL under SDL 1.3

Why doesn’t SDL_DisplayFormat() work. I need to match my images with the
current display format.

SDL_TextureID nID = SDL_CreateTextureFromSurface( NULL, pSurface );

// nID is non-zero, so it created a texture from the surface that was loaded

ISSUE 2 is that when I draw the texture using SDL_RenderCopy() I get an
image that looks like it has a stride issue and the color is off.

I did not create a SDL Renderer, since the minimum sprite sample skips that
and uses a default renderer.

I can provide a sample image that shows this.

Has anyone run into this? Are there any suggestions on what I can try to
(hopefully) fix either of these two issues?

Ken

It appears ISSUE 2 is related to the TGA image format. If I convert the
file to a PNG it loads and displays correctly.

Since the loading of the image is handled by SDL_image, it appears that it
doesn’t handle the TGA format correctly when compiled against SDL 1.3, but
DOES handle it correctly when compiled against SDL 1.2.x.

BTW, I am using SDL 1.3.0 Revision 5427

Ken> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ken Rogoway
Sent: Tuesday, December 22, 2009 12:32 AM
To: 'SDL Development List’
Subject: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not working
under SDL 1.3

I am trying to get my game working with the new 1.3 API, and have the
following two issues:

Code snippet:

SDL_Surface *pSurface = IMG_Load( “background.tga” );

SDL_Surface *pNewSurface = SDL_DisplayFormat( pSurface ); // ISSUE 1:
NewSurface is NULL under SDL 1.3

Why doesn’t SDL_DisplayFormat() work. I need to match my images with the
current display format.

SDL_TextureID nID = SDL_CreateTextureFromSurface( NULL, pSurface );

// nID is non-zero, so it created a texture from the surface that was loaded

ISSUE 2 is that when I draw the texture using SDL_RenderCopy() I get an
image that looks like it has a stride issue and the color is off.

I did not create a SDL Renderer, since the minimum sprite sample skips that
and uses a default renderer.

I can provide a sample image that shows this.

Has anyone run into this? Are there any suggestions on what I can try to
(hopefully) fix either of these two issues?

Ken


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

ISSUE 1 is because with SDL 1.3 I do not call SDL_SetVideoMode() since I am
using the new API.

It looks like I can just skip converting using SDL_DisplayFormat() if I am
using the new API.

However, I still have an issue when calling SDL_CreateTextureFromSurface(
NULL, pSurface ); with some surfaces loaded using IMG_Load().

Ken

Behalf Of Ken RogowayFrom: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Sent: Tuesday, December 22, 2009 1:07 AM
To: 'SDL Development List’
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

It appears ISSUE 2 is related to the TGA image format. If I convert the

file to a PNG it loads and displays correctly.

Since the loading of the image is handled by SDL_image, it appears that it

doesn’t handle the TGA format correctly when compiled against SDL 1.3, but

DOES handle it correctly when compiled against SDL 1.2.x.

BTW, I am using SDL 1.3.0 Revision 5427

Can you submit a bug report to bugzilla and make sure you include the
image that you’re having trouble with, along with a description of
your OS and video settings?

Thanks!
–SamOn Tue, Dec 22, 2009 at 8:45 AM, Ken Rogoway wrote:

ISSUE 1 is because with SDL 1.3 I do not call SDL_SetVideoMode() since I am
using the new API.

It looks like I can just skip converting using SDL_DisplayFormat() if I am
using the new API.

However, I still have an issue when calling SDL_CreateTextureFromSurface(
NULL, pSurface ); with some surfaces loaded using IMG_Load().

Ken

From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ken Rogoway
Sent: Tuesday, December 22, 2009 1:07 AM
To: 'SDL Development List’
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

It appears ISSUE 2 is related to the TGA image format.? If I convert the

file to a PNG it loads and displays correctly.

Since the loading of the image is handled by SDL_image, it appears that it

doesn’t handle the TGA format correctly when compiled against SDL 1.3, but

DOES handle it correctly when compiled against SDL 1.2.x.

BTW, I am using SDL 1.3.0 Revision 5427


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I may be wrong, but SDL_image doesn’t seem ready yet
to work with SDL 1.3, given that the SDL_Surface structure
seems to have changed.
I tried as well to load an image that way and display it, and
it crashed.
Julien CLEMENT________________________________
De : “sdl-request at lists.libsdl.org
? : sdl at lists.libsdl.org
Envoy? le : Mar 22 D?cembre 2009, 20 h 35 min 08 s
Objet : SDL Digest, Vol 36, Issue 69

Send SDL mailing list submissions to
sdl at lists.libsdl.org

To subscribe or unsubscribe via the World Wide Web, visit
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
or, via email, send a message with subject or body ‘help’ to
sdl-request at lists.libsdl.org

You can reach the person managing the list at
sdl-owner at lists.libsdl.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of SDL digest…”

Today’s Topics:

  1. Re: Doctor Doctor! …my first game in c++ with SDL…
    (Bob Pendleton)
  2. Re: SDL_DisplayFormat and CreateTextureFromSurface not
    working under SDL 1.3 (Ken Rogoway)
  3. Re: SDL_mixer and iPhone (labriola)
  4. Re: SDL_DisplayFormat and CreateTextureFromSurface not
    working under SDL 1.3 (Sam Lantinga)
  5. Re: Doctor Doctor! …my first game in c++ with SDL…
    (a_kutluozen)
  6. Re: mysterious crash with SDL_mixer (Ryan C. Gordon)
  7. Re: Doctor Doctor! …my first game in c++ with SDL…
    (Bob Pendleton)

Message: 1
Date: Tue, 22 Dec 2009 08:58:12 -0600
From: bob@pendleton.com (Bob Pendleton)
To: SDL Development List
Subject: Re: [SDL] Doctor Doctor! …my first game in c++ with SDL…
Message-ID:
<9aac2d770912220658w62cb2f16m7629d3ff962fa181 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Dec 22, 2009 at 5:43 AM, Christoph Nelles wrote:

Hi,

sorry, i forgot, this is the mailing list where every programming language
younger than 30 years is considered evil.

On Mon, 21 Dec 2009 18:02:20 -0600, Bob Pendleton wrote:

Using wget is a perfectly reasonable thing to do because most web
based malware attacks can’t touch wget. They might crash it, but they

Most means not all. So implicitly there are attack vectors. A short google
search reveals that even wget has (had) its share of exploits.

won’t infect it. If the URL you posted does not work with wget, it is
perfectly reasonable to suspect bad intent on the part of the site and

Sure, the web is full of evil. Setting a web site before a download is
completely legal too. To prevent deep linking, allow/force selection of
server, showing premium features, etc. Filefront, gameeshell.com, chip.de,
SF.net, are all these evil? (Btw. google is evil.)
Is your browser your last line of defense against malware? No virus
scanner, no reduced user privileges? How about hardening your browser?

possibly of the poster. No one with an understanding of malware
attacks would drop an unknown URL into a popular browser. The risk of
enabling an attack is too high.

So you never leave google.com (or even about:blank)?

You might also want to reconsider the use of sarcasm in email. The
person you are replying to is always going to take it badly.

It’s more cynicism than sarcasm.

Enough bitching around. Perhaps we should talk privately about these
topics.

No need, you’ve told me all I want to know about you.


Christoph Nelles

E-Mail ? ?: evilazrael at evilazrael.de
Jabber ? ?: eazrael at evilazrael.net ? ? ?ICQ ? ? ? : 78819723

PGP-Key ? : ID 0x424FB55B on subkeys.pgp.net
? ? ? ? ? ?or http://evilazrael.net/pgp.txt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------


Message: 2
Date: Tue, 22 Dec 2009 10:45:02 -0600
From: ken@homebrewsoftware.com (Ken Rogoway)
To: “‘SDL Development List’”
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3
Message-ID: 0efd01ca8326$1c786a90$55693fb0$@com
Content-Type: text/plain; charset=“us-ascii”

ISSUE 1 is because with SDL 1.3 I do not call SDL_SetVideoMode() since I am
using the new API.

It looks like I can just skip converting using SDL_DisplayFormat() if I am
using the new API.

However, I still have an issue when calling SDL_CreateTextureFromSurface(
NULL, pSurface ); with some surfaces loaded using IMG_Load().

Ken

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ken Rogoway
Sent: Tuesday, December 22, 2009 1:07 AM
To: 'SDL Development List’
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

It appears ISSUE 2 is related to the TGA image format. If I convert the

file to a PNG it loads and displays correctly.

Since the loading of the image is handled by SDL_image, it appears that it

doesn’t handle the TGA format correctly when compiled against SDL 1.3, but

DOES handle it correctly when compiled against SDL 1.2.x.

BTW, I am using SDL 1.3.0 Revision 5427


Message: 3
Date: Tue, 22 Dec 2009 02:14:47 -0800
From: labriolaharris@yahoo.in (labriola)
To: sdl at lists.libsdl.org
Subject: Re: [SDL] SDL_mixer and iPhone
Message-ID: <1261476887.m2f.21124 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

How much does a new iPhone cost per month? Hi. I’ve been planning on buying an iPhone and recently my old phone broke so I would like to get it sooner rather than later. However, I do not know what the monthly cost would be. I am currently on a family plan with unlimited text messaging. Does anyone know how much it would cost per month to drop my old Razr and pick up a new iPhone? Or a helpful link would be great too. Thanks!


old is gold


Message: 4
Date: Tue, 22 Dec 2009 09:51:40 -0800
From: slouken@libsdl.org (slouken)
To: SDL Development List
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3
Message-ID:
<3adffa60912220951j3ce638f8hd796a0a0af82c17d at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Can you submit a bug report to bugzilla and make sure you include the
image that you’re having trouble with, along with a description of
your OS and video settings?

Thanks!
–Sam

On Tue, Dec 22, 2009 at 8:45 AM, Ken Rogoway wrote:

ISSUE 1 is because with SDL 1.3 I do not call SDL_SetVideoMode() since I am
using the new API.

It looks like I can just skip converting using SDL_DisplayFormat() if I am
using the new API.

However, I still have an issue when calling SDL_CreateTextureFromSurface(
NULL, pSurface ); with some surfaces loaded using IMG_Load().

Ken

From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ken Rogoway
Sent: Tuesday, December 22, 2009 1:07 AM
To: 'SDL Development List’
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

It appears ISSUE 2 is related to the TGA image format.? If I convert the

file to a PNG it loads and displays correctly.

Since the loading of the image is handled by SDL_image, it appears that it

doesn’t handle the TGA format correctly when compiled against SDL 1.3, but

DOES handle it correctly when compiled against SDL 1.2.x.

BTW, I am using SDL 1.3.0 Revision 5427


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC


Message: 5
Date: Tue, 22 Dec 2009 10:10:14 -0800
From: great_tuorelensar@hotmail.com (a_kutluozen)
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Doctor Doctor! …my first game in c++ with SDL…
Message-ID: <1261505414.m2f.21130 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”

guys, ok speaking and arguing is good but what is interest with my game? i want only some informations about this wget and uploading my game…for sharing knowledges and a little fun:) so i used rapidshare and megashare for sharing my game and sources, couldn’t you download it?? is it really big problem to arguing like this?? if you can download my game, please play it and write your comments, i need your comments about my game and codes;) :slight_smile:


Message: 6
Date: Tue, 22 Dec 2009 13:48:15 -0500
From: icculus@icculus.org (icculus)
To: SDL Development List
Subject: Re: [SDL] mysterious crash with SDL_mixer
Message-ID: <4B31146F.7060804 at icculus.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Okay, so after a lot more digging I found the culprit. In
SDL_audiotypecvt.c there are a lot of lines like this:

I’m poking around this code today, so this will be fixed in revision
control soon.

–ryan.


Message: 7
Date: Tue, 22 Dec 2009 13:33:20 -0600
From: bob@pendleton.com (Bob Pendleton)
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Doctor Doctor! …my first game in c++ with SDL…
Message-ID:
<9aac2d770912221133m24d6834j25c58af58abbf26b at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

On Tue, Dec 22, 2009 at 12:10 PM, a_kutluozen <great_tuorelensar at hotmail.com wrote:

guys, ok speaking and arguing is good but what is interest with my game?
i want only some informations about this wget and uploading my game…for
sharing knowledges and a little fun:) so i used rapidshare and megashare for
sharing my game and sources, couldn’t you download it?? is it really big
problem to arguing like this?? if you can download my game, please play it
and write your comments, i need your comments about my game and codes;)

The “arguing” had nothing to do with your game or you. Just ignore it. The
fact that your code was hard to get to is a problem you need to address.

If people have trouble downloading your code, they won’t spend a lot of time
trying to get it. A very few will send you a comment telling you about the
problem. (When I did the same thing I didn’t figure out what was wrong for a
long time. Nobody took the effort to tell me there was a problem.) You
really have to use download sites that can be reached by all users. If they
can’t be accessed by standard tools like wget, or the site requires that you
register, people will just give up trying to get your code. There are many
places like google code and sourceforge where you can set up an download
site and and anyone can access it. It may be possible to do the same on
rapidshare and megashare, it don’t know, I don’t use those site. But, it is
up to you to make sure it is as easy as possible for people to get your
code. It can take a while to learn how to do that. Don’t worry about it.
You’ll learn it.

The key thing to remember is that when you post something you are asking
people to spend time on you. They spend time on you for pretty much two
reasons, 1) the goodness of their hearts, and 2) the hope that by helping
you they will get something of value for themselves. In this case the
something of value is the opportunity to learn. Our time is the only thing
of true value we have.

Bob Pendleton

P.S.

These words were engraved on a block of wood nailed to the wall above my
grandfathers desk:

“Illegitimi non carborundum” which is not Latin and doesn’t actually mean
anything. But, he thought it meant "don’t let the bastards grind you down"
which is very good advice. I should remember it more often.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

End of SDL Digest, Vol 36, Issue 69


I may be wrong, but SDL_image doesn’t seem ready yet
to work with SDL 1.3, given that the SDL_Surface structure
seems to have changed.
I tried as well to load an image that way and display it, and
it crashed.
Julien CLEMENT

SDL_Image works just fine once you recompile the code
against the SDL 1.3 headers so it #includes the updated
SDL_Surface definition.>From: julien CLEMENT

Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not working under SDL 1.3

My bug was duplicated with SDL 1.3, SDL_image-1.2.10 compiled against SDL
1.3. I have provided detailed instructions in Bugzilla along with some
sample images to show the problem. I put it under the SDL 1.3 bugs since I
suspect it is related to the SDL_CreateTextureFromSurface() call.> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Mason Wheeler
Sent: Tuesday, December 22, 2009 4:55 PM
To: SDL Development List
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

From: julien CLEMENT
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

I may be wrong, but SDL_image doesn’t seem ready yet
to work with SDL 1.3, given that the SDL_Surface structure
seems to have changed.
I tried as well to load an image that way and display it, and
it crashed.
Julien CLEMENT

SDL_Image works just fine once you recompile the code
against the SDL 1.3 headers so it #includes the updated
SDL_Surface definition.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This is fixed, thanks!On Tue, Dec 22, 2009 at 3:10 PM, Ken Rogoway wrote:

My bug was duplicated with SDL 1.3, SDL_image-1.2.10 compiled against SDL
1.3. ?I have provided detailed instructions in Bugzilla along with some
sample images to show the problem. ?I put it under the SDL 1.3 bugs since I
suspect it is related to the SDL_CreateTextureFromSurface() call.

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Mason Wheeler
Sent: Tuesday, December 22, 2009 4:55 PM
To: SDL Development List
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

From: julien CLEMENT
Subject: Re: [SDL] SDL_DisplayFormat and CreateTextureFromSurface not
working under SDL 1.3

I may be wrong, but SDL_image doesn’t seem ready yet
to work with SDL 1.3, given that the SDL_Surface structure
seems to have changed.
I tried as well to load an image that way and display it, and
it crashed.
Julien CLEMENT

SDL_Image works just fine once you recompile the code
against the SDL 1.3 headers so it #includes the updated
SDL_Surface definition.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC