severity 663514 serious
reassign 663514 src:sdlgfx
found 663514 2.0.23-1
tags 663514 patch
user ubuntu-de...@lists.ubuntu.com
usertags 663514 ubuntu-patch quantal
thanks

Hi there,

> This package FTBFS on my Xen and KVM based VMs on i386 (but not amd64):

The problem is definitely not specific to Xen/KVM.  An i386 chroot on an
Ubuntu system shows the same build failure:

  https://bugs.launchpad.net/debian/+source/libsdl-perl/+bug/1029981

The problem is that the cpuFlags() function used for querying cpuid is
returning garbage data from the stack.  So the sdl-perl test suite passes if
the garbage returned happens to not have the MMX bit set both times, and
otherwise it fails.

I've done some analysis on the linked Ubuntu bug, showing the bug in the
disassembled binary, and uploaded a fixed package to Ubuntu which I've
confirmed detects mmx support properly and lets libsdl-perl's test suite
pass reliably.

The attached patch should be suitable for uploading to Debian as well. 
Please consider applying it at your earliest convenience, or let me know if
you would like me to NMU instead.

Since this bug in practice causes libsdl-perl to not be reliably rebuildable
(more precisely, causes its buildability to depend entirely on random
unrelated permutations of the stack, which may change over the lifetime of
wheezy), I'm marking this bug as 'serious' for the release.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
=== modified file 'debian/changelog'
--- old/debian/changelog	2011-12-30 20:55:51 +0000
+++ new/debian/changelog	2012-07-31 08:25:59 +0000
@@ -1,3 +1,12 @@
+sdlgfx (2.0.23-1.1) UNRELEASED; urgency=high
+
+  * Non-maintainer upload.
+  * High-urgency upload for RC bugfix.
+  * debian/patches/wrong-cpuid-mmx-detection.patch: fix mmx cpuid
+    detection.  Closes: #663514, LP: #1029981.
+
+ -- Steve Langasek <vor...@debian.org>  Tue, 31 Jul 2012 01:21:22 -0700
+
 sdlgfx (2.0.23-1) unstable; urgency=low
 
   [ Felix Geyer ]

=== modified file 'debian/patches/series'
--- old/debian/patches/series	2009-04-30 14:34:05 +0000
+++ new/debian/patches/series	2012-07-31 08:25:27 +0000
@@ -1 +1,2 @@
 010_primitives_spell.diff
+wrong-cpuid-mmx-detection.patch

=== added file 'debian/patches/wrong-cpuid-mmx-detection.patch'
--- old/debian/patches/wrong-cpuid-mmx-detection.patch	1970-01-01 00:00:00 +0000
+++ new/debian/patches/wrong-cpuid-mmx-detection.patch	2012-07-31 08:25:27 +0000
@@ -0,0 +1,35 @@
+Description: fix mmx cpuid detection
+ The MMX detection in SDL_imageFilter.c contains buggy assembly which reads
+ garbage values off the stack.  This usually results in MMX not being used
+ on i386; sometimes it instead causes the test suite to fail.  At runtime it
+ could also cause MMX instructions to be used on non-MMX machines.
+ .
+ Replace this cpu detection code with code that doesn't rely on the stack
+ pointer staying the same after popa.
+Author: Steve Langasek <steve.langa...@canonical.com>
+Bug: http://sourceforge.net/support/tracker.php?aid=3550046
+Bug-Debian: http://bugs.debian.org/663514
+Bug-Ubuntu: https://launchpad.net/bugs/1029981
+
+Index: sdlgfx-2.0.23/SDL_imageFilter.c
+===================================================================
+--- sdlgfx-2.0.23.orig/SDL_imageFilter.c
++++ sdlgfx-2.0.23/SDL_imageFilter.c
+@@ -80,12 +80,12 @@
+ 			popa
+ 	}
+ #else
+-	asm volatile ("pusha		     \n\t" "mov    %1, %%eax     \n\t"	/* request feature flag */
++	asm volatile ("pusha		     \n\t" "mov    %0, %%eax     \n\t"	/* request feature flag */
+ 		"cpuid                \n\t"	/* get CPU ID flag */
+-		"mov    %%edx, %0     \n\t"	/* move result to mmx_bit */
+-		"popa		     \n\t":"=m" (flags)	/* %0 */
+-		:"i"(0x00000001)	/* %1 */
+-		);
++		"mov    %%edx, 0(%1)  \n\t"	/* move result to mmx_bit */
++		"popa		     \n\t":
++		:"i"(0x00000001), "S"(&flags)	/* %0, %1 */
++		: "memory");
+ #endif
+ #endif
+ 

Attachment: signature.asc
Description: Digital signature

Reply via email to