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 1278

Summary: Crash in SDL_UnlockYUVOverlay with smpeg
Product: SDL Reporter: Anton Yarth <llancelot7>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus, llancelot7
Version: 1.2.14   
Hardware: x86   
OS: Linux   
Attachments: App for demonstration of bug

Description Anton Yarth 2011-08-16 01:59:16 UTC
After sdl update in my distro from version from 2009 year to current(update from 12 august 2011) appears bugs with smpeg.
Video-files with resolution 320x168(and other) plays like that:
http://img221.imageshack.us/img221/9692/bugkf.jpg
but must be:
http://img62.imageshack.us/img62/5854/goodlu.jpg

And in sometimes with other video-files project crashes with this callstack:
http://img402.imageshack.us/img402/5536/callstack.png
(Sometimes this window shows 0x00008800 instead of SDL_UnlockYUVOverlay)
Comment 1 Anton Yarth 2011-08-16 02:09:46 UTC
On files with resolution 320x172 all looks OK
Comment 2 Anton Yarth 2011-08-17 19:40:33 UTC
Oh, i found bug. This bug steel presents while SDL_ASSEMBLY_ROUTINES is defined. Turning it off gives no errors and crashes. I think it's gcc 4.6.1 optimization problem.
Comment 3 Anton Yarth 2011-08-17 19:47:44 UTC
hmm, peoples from tests code and answer what sdl use not correct asm code, that cause errors(such as no compilation on gcc 4.6.1 with -O0 flag), and that regression.
Comment 4 Anton Yarth 2011-08-21 19:28:40 UTC
Created attachment 678 [details]
App for demonstration of bug
Comment 5 Anton Yarth 2011-08-21 19:37:38 UTC
With gcc 4.6.1 sdl-code cause this bug until comment #define SDL_ASSEMBLY_ROUTINES 1", and with -O0 optimization it give wrong mmx code.
This bug, marked as "bug of sdl" on gcc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50111
And this bug marked as "bug of sdl" on Archlinux https://bugs.archlinux.org/task/25634
Comment 6 Sam Lantinga 2011-09-06 19:49:17 UTC
This is fixed in Mercurial:
http://hg.libsdl.org/SDL/rev/819e85555d4d

Thanks!
Comment 7 Anton Yarth 2011-09-06 23:31:11 UTC
No appears:
./src/video/SDL_RLEaccel.c: In function ‘SDL_RLEBlit’:
./src/video/SDL_RLEaccel.c:831:5: error: impossible constraint in ‘asm’
.... /*many lines*/
./src/video/SDL_RLEaccel.c:831:5: error: impossible constraint in ‘asm’
./src/video/SDL_RLEaccel.c:930:6: error: impossible constraint in ‘asm’
..../*many lines*/
./src/video/SDL_RLEaccel.c:930:6: error: impossible constraint in ‘asm’
Comment 8 Ryan C. Gordon 2011-09-12 11:18:13 UTC
This bug is happening on Haiku, too:


   http://buildbot.libsdl.org/builders/sdl-haiku/builds/21/steps/compile/logs/stdio


--ryan.
Comment 9 Ryan C. Gordon 2011-09-12 11:19:11 UTC
(In reply to comment #8)
> This bug is happening on Haiku, too:

Specifically: the "impossible constraint" error, I mean.

Should we just disable the MMX code across the board?

--ryan.
Comment 10 Anton Yarth 2011-09-12 17:51:08 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > This bug is happening on Haiku, too:
> 
> Specifically: the "impossible constraint" error, I mean.
> 
> Should we just disable the MMX code across the board?
> 
> --ryan.

By your patch in mercurial (http://hg.libsdl.org/SDL/rev/739ad55fe50d) not disabled all mmx-code, SDL_yuv_sw.c and SDL_yuv_mmx.c still cause not correct drawning or crashes, because they have mmx-instructions too.
Comment 11 Anton Yarth 2011-09-12 18:00:10 UTC
And if i try build sdl-1.2 from current(2011-09-13  07:58) mercurial with CFLAGS="-O0 -g" it's now stops on:
./src/video/SDL_blit_A.c: In function ‘BlitRGBtoRGBSurfaceAlpha128MMX’:
./src/video/SDL_blit_A.c:247:3: error: impossible constraint in ‘asm’
./src/video/SDL_blit_A.c:247:3: error: impossible constraint in ‘asm’
make: *** [build/SDL_blit_A.lo] Error 1

I think we must disable mmx code in all files with blitting.
Comment 12 Ryan C. Gordon 2011-09-13 11:01:43 UTC
(In reply to comment #10)
> By your patch in mercurial (http://hg.libsdl.org/SDL/rev/739ad55fe50d) not
> disabled all mmx-code, SDL_yuv_sw.c and SDL_yuv_mmx.c still cause not correct
> drawning or crashes, because they have mmx-instructions too.

I wasn't trying to disable this code with that patch.

--ryan.
Comment 13 Ryan C. Gordon 2011-09-13 11:50:43 UTC
Screw it, I turned off the rest of the MMX code.

Fixed in hg changeset 867c4c3604b7.

--ryan.