Bug 31345 - libsdl-1.2.6 gives illegal instruction crash
Bug#: 31345 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: games@gentoo.org Reported By: paul@cablon.nl
Component: Library
URL:  http://www.libsdl.org/pipermail/sdl/2003-October/057304.html
Summary: libsdl-1.2.6 gives illegal instruction crash
Keywords:  
Status Whiteboard: 
Opened: 2003-10-17 05:19 0000
Description:   Opened: 2003-10-17 05:19 0000
running enigma with libsdl-1.2.6 or libsdl-1.2.6-r1 crashes within 2 seconds 
with an Illegal instruction. Downgrading to libsdl-1.2.5-r2 solves the problem. 
gdb enigma gives the following information: 
Program received signal SIGILL, Illegal instruction. 
[Switching to Thread 16384 (LWP 11515)] 
0x40033bc0 in BlitRGBtoRGBPixelAlphaMMX3DNOW () from /usr/lib/libSDL-1.2.so.0 
 

Reproducible: Always
Steps to Reproduce:
1. emerge enigma 
2. emerge rsync 
3. emerge world -u -p 
4. enigma 
Actual Results:  
The program shows the title screen and disappears. The command prompt displays 
the text "Illegal instruction" 

Expected Results:  
Not crashed 

emerge info 
Portage 2.0.49-r13-2 (default-x86-1.4, gcc-3.2.3, glibc-2.3.2-r1, 2.4.22) 
================================================================= 
System uname: 2.4.22 i686 Intel(R) Pentium(R) 4 CPU 2.60GHz 
Gentoo Base System version 1.4.3.10p1 
ccache version 2.2 [enabled] 
ACCEPT_KEYWORDS="x86" 
AUTOCLEAN="yes" 
CFLAGS="-march=pentium4 -O3 -pipe" 
CHOST="i686-pc-linux-gnu" 
COMPILER="gcc3" 
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config 
/usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb 
/usr/kde/3.1/share/config /usr/share/texmf/tex/generic/config/ 
/usr/share/texmf/tex/platex/config/" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" 
CXXFLAGS="-march=pentium4 -O3 -pipe" 
DISTDIR="/usr/portage/distfiles" 
FEATURES="autoaddcvs sandbox ccache buildpkg" 
GENTOO_MIRRORS="http://ftp.easynet.nl/mirror/gentoo/ 
http://gentoo.mirror.sdv.fr http://ftp.snt.utwente.nl/pub/os/linux/gentoo 
http://ftp.gentoo.skynet.be/pub/gentoo/ 
http://mirrors.sec.informatik.tu-darmstadt.de/gentoo" 
MAKEOPTS="-j4" 
PKGDIR="/usr/portage/packages" 
PORTAGE_TMPDIR="/var/tmp" 
PORTDIR="/usr/portage" 
PORTDIR_OVERLAY="" 
SYNC="rsync://rsync.gentoo.org/gentoo-portage" 
USE="x86 oss apm avi crypt encode foomaticdb gif jpeg gnome libg++ mad mikmod 
mpeg ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib gtkhtml 
gdbm berkdb slang readline arts tetex bonobo svga ggi java guile mysql X sdl 
gpm tcpd pam libwww ssl perl python imlib oggvorbis gtk qt kde motif opengl 
mozilla acpi alsa cdr dvd esd gphoto2 pcmcia pda pnp aalib cups"

------- Comment #1 From SpanKY 2003-10-18 00:04:27 0000 -------
could you try this ?
export EXTRA_ECONF="--disable-nasm"
emerge libsdl

------- Comment #2 From paul@cablon.nl 2003-10-18 03:11:35 0000 -------
Okay, I've tried that. It gives exactly the same problem as I had originally.

------- Comment #3 From paul@cablon.nl 2003-10-18 07:06:20 0000 -------
I've been looking at the source code, unencumbered by much linux programming
knowledge...
The problem seems to occur in BlitRGBtoRGBPixelAlphaMMX3DNOW, which is interesting
as my P4 doesn't have any 3DNow instructions. Looking for the function call
we see in src/video/SDL_blit_A.c line 1457

f=CPU_Flags();
if((f&(TDNOW_CPU|MMX_CPU))==(TDNOW_CPU|MMX_CPU))
  return BlitRGBtoRGBPixelAlphaMMX3DNOW;

CPU_Flags seems to be the result of a cpuid call, EAX=1 - standard level
flags. Unfortunately, as far as I can see, the 3dnow flag is not part of
the standard level flags, but part of the extended level flags (see http://www.sandpile.org/ia32/cpuid.htm).
The code checks the correct bit, but doesn't have the necessary information
available. Again, without much further knowledge, I would evaluate this as
a libSDL bug.
Hope this makes sense.

------- Comment #4 From Tyler Nielsen 2003-10-19 19:46:40 0000 -------
I ran into this also (with castle-combat).  Looking at the sdl archives they
know about it and have a plan to fix it.  Until then I'll just run 1.2.5

------- Comment #5 From James Harlow (RETIRED) 2003-10-30 12:34:52 0000 -------
*** Bug 30643 has been marked as a duplicate of this bug. ***

------- Comment #6 From James Harlow (RETIRED) 2003-10-30 12:50:16 0000 -------
*** Bug 29205 has been marked as a duplicate of this bug. ***

------- Comment #7 From Mr. Bones. 2003-11-01 00:21:39 0000 -------
I just added libsdl-1.2.6-r2.ebuild to CVS.  Please try it out and see if
it makes a difference for you.

Thanks.

------- Comment #8 From paul@cablon.nl 2003-11-01 05:53:57 0000 -------
I just tried, but I couldn't install it.

root # emerge libsdl -u
Calculating dependencies ...done!
>>> emerge (1 of 1) media-libs/libsdl-1.2.6-r2 to /
>>> md5 src_uri ;-) SDL-1.2.6.tar.gz
>>> Unpacking source...
>>> Unpacking SDL-1.2.6.tar.gz to /var/tmp/portage/libsdl-1.2.6-r2/work
patching file src/video/xbios/SDL_xbios.c
Hunk #1 FAILED at 22.
1 out of 2 hunks FAILED -- saving rejects to file src/video/xbios/SDL_xbios.c.rej
patching file src/video/xbios/SDL_xbios.c
Hunk #1 FAILED at 22.
1 out of 2 hunks FAILED -- saving rejects to file src/video/xbios/SDL_xbios.c.rej
patching file src/video/x11/SDL_x11modes.c
Hunk #1 FAILED at 22.
1 out of 2 hunks FAILED -- saving rejects to file src/video/x11/SDL_x11modes.c.rej

!!! ERROR: media-libs/libsdl-1.2.6-r2 failed.
!!! Function src_unpack, Line 37, Exitcode 1
!!! patch failed

------- Comment #9 From Mr. Bones. 2003-11-01 14:17:40 0000 -------
Yeah, I dorked up the patch with RCS ids.  I've fixed it in CVS, so please
resync and try it again.  Thanks.

------- Comment #10 From paul@cablon.nl 2003-11-02 02:05:51 0000 -------
Yep, that seems to work. Thanks for the effort.