Blitting crash!

Hi!

I have found crash in blitting alpha surface on SDL 1.2.6.
I have read your changelog for 1.2.6
http://www.libsdl.org/release/changes-1.2.html:
1.2.6: Added MMX and 3DNow! optimized alpha blitters (thanks Stephane!)

Attached example crash in SDL_BlitSurface() with message “Illegal
Instruction” This crash work only on linux(RH8) and CPU Celeron (see
cpuinfo) from Intel… Example don’t crashed on CPU from AMD and other CPUs
Pentium-3, and Pentium-2, etc…

cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel® Celeron® CPU 2.00GHz
stepping : 9
cpu MHz : 2018.003
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 4023.91

I use many build of SDL-1.2.6
(includehttp://www.libsdl.org/release/SDL-1.2.6-1.i386.rpm )

Best regards!
Vladimir Davydov

-------------- next part --------------
A non-text attachment was scrubbed…
Name: test-sdl.tar.gz
Type: application/x-tgz
Size: 2926 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20031015/48faf7fa/attachment.bin

Vladimir Davydov (by way of Vladimir Davydov < @iqmedia.com="">) wrote:

Hi!

I have found crash in blitting alpha surface on SDL 1.2.6.
I have read your changelog for 1.2.6
http://www.libsdl.org/release/changes-1.2.html:
1.2.6: Added MMX and 3DNow! optimized alpha blitters (thanks Stephane!)

Attached example crash in SDL_BlitSurface() with message “Illegal
Instruction” This crash work only on linux(RH8) and CPU Celeron (see
cpuinfo) from Intel… Example don’t crashed on CPU from AMD and other CPUs
Pentium-3, and Pentium-2, etc…

Could you please provide me with a backtrace ?
(use gdb ./program, then type “run”, then when it crashes type “bt” and
send me the output)

Stephane

Hi!

This is backtrace:
gdb ./crash
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-redhat-linux”…
(gdb) run
Starting program: /crash
[New Thread 8192 (LWP 3893)]
[New Thread 16385 (LWP 3900)]
[New Thread 8194 (LWP 3901)]
Display

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 8192 (LWP 3893)]
0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from /usr/lib/libSDL-1.2.so.0
(gdb) bt
#0 0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from
/usr/lib/libSDL-1.2.so.0
#1 0x4002e8f1 in SDL_SoftBlit () from /usr/lib/libSDL-1.2.so.0
#2 0x40045e98 in SDL_LowerBlit () from /usr/lib/libSDL-1.2.so.0
#3 0x400460ed in SDL_UpperBlit () from /usr/lib/libSDL-1.2.so.0
#4 0x08048ab5 in main (argc=1 ‘\001’, argv=0xbfffdca4) at crash.cc:43
#5 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)> Vladimir Davydov (by way of Vladimir Davydov < @iqmedia.com="">) wrote:

Hi!

I have found crash in blitting alpha surface on SDL 1.2.6.
I have read your changelog for 1.2.6
http://www.libsdl.org/release/changes-1.2.html:
1.2.6: Added MMX and 3DNow! optimized alpha blitters (thanks Stephane!)

Attached example crash in SDL_BlitSurface() with message “Illegal
Instruction” This crash work only on linux(RH8) and CPU Celeron (see
cpuinfo) from Intel… Example don’t crashed on CPU from AMD and other
CPUs Pentium-3, and Pentium-2, etc…

Could you please provide me with a backtrace ?
(use gdb ./program, then type “run”, then when it crashes type “bt” and
send me the output)

Stephane


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Vladimir Davydov wrote:

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 8192 (LWP 3893)]
0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from /usr/lib/libSDL-1.2.so.0
(gdb) bt
#0 0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from
/usr/lib/libSDL-1.2.so.0
#1 0x4002e8f1 in SDL_SoftBlit () from /usr/lib/libSDL-1.2.so.0
#2 0x40045e98 in SDL_LowerBlit () from /usr/lib/libSDL-1.2.so.0
#3 0x400460ed in SDL_UpperBlit () from /usr/lib/libSDL-1.2.so.0
#4 0x08048ab5 in main (argc=1 ‘\001’, argv=0xbfffdca4) at crash.cc:43
#5 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)

Thanks !

After some documentation I found intel uses the 3dnow cpuid bit for
something else called “Pending break enable” and your cpu has it set.
That means more cpu detection code is needed at this point, so we
basically have two choices :

  • replace each CPU_Flags() call with a big macro that calls cpuid twice
    to first check for extended cpuid, then for 3dnow if extended cpuid is
    available
  • replace each CPU_Flags() call with a simple test for some internal SDL
    flags that tells which processor features are available, and add cpu
    detection at SDL start up to fill those flags.

I prefer the seconde one, because cpuid is a serializing instruction, so
we might get some speed up by removing it (and some slow down if we
start calling it twice for each blit !).

Opinions ?

Stephane

Vladimir Davydov wrote:

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 8192 (LWP 3893)]
0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from
/usr/lib/libSDL-1.2.so.0 (gdb) bt
#0 0x4003acb4 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from
/usr/lib/libSDL-1.2.so.0
#1 0x4002e8f1 in SDL_SoftBlit () from /usr/lib/libSDL-1.2.so.0
#2 0x40045e98 in SDL_LowerBlit () from /usr/lib/libSDL-1.2.so.0
#3 0x400460ed in SDL_UpperBlit () from /usr/lib/libSDL-1.2.so.0
#4 0x08048ab5 in main (argc=1 ‘\001’, argv=0xbfffdca4) at crash.cc:43
#5 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)

Thanks !

After some documentation I found intel uses the 3dnow cpuid bit for
something else called “Pending break enable” and your cpu has it set.
That means more cpu detection code is needed at this point, so we
basically have two choices :

  • replace each CPU_Flags() call with a big macro that calls cpuid twice
    to first check for extended cpuid, then for 3dnow if extended cpuid is
    available
  • replace each CPU_Flags() call with a simple test for some internal SDL
    flags that tells which processor features are available, and add cpu
    detection at SDL start up to fill those flags.

I prefer the seconde one, because cpuid is a serializing instruction, so
we might get some speed up by removing it (and some slow down if we
start calling it twice for each blit !).

Opinions ?

Stephane

I definitely agree with 2nd approach.
Who make it? I or you? :slight_smile:

Vladimir