Bug 435771 - gst-inspect-0.10 crashes on PPC/PPC64
gst-inspect-0.10 crashes on PPC/PPC64
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: liboil (Show other bugs)
rawhide
All Linux
low Severity low
: ---
: ---
Assigned To: Behdad Esfahbod
Fedora Extras Quality Assurance
:
Depends On:
Blocks: F-ExcludeArch-ppc FE-ExcludeArch-ppc64
  Show dependency treegraph
 
Reported: 2008-03-03 14:35 EST by Bastien Nocera
Modified: 2008-03-12 18:38 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-03-12 16:53:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to use a different register (1.67 KB, patch)
2008-03-12 18:38 EDT, David Woodhouse
no flags Details | Diff

  None (edit)
Description Bastien Nocera 2008-03-03 14:35:31 EST
http://koji.fedoraproject.org/koji/getfile?taskID=472809&name=build.log
and
http://koji.fedoraproject.org/koji/getfile?taskID=472812&name=build.log

Not a lot of debug. It's probably an optimisation problem on PPC caused by GCC
4.3 in liboil.

Reproducer:
- Have a rawhide PPC/PPC64 machine at hand
- install gstreamer-0.10.17-2.fc9 and liboil 0.3.13
- run "gst-inspect-0.10" and see it crash
Comment 1 David Woodhouse 2008-03-04 03:20:56 EST
Sure it's not the Altivec stuff in liboil again?
Comment 2 Bastien Nocera 2008-03-04 06:04:30 EST
It's PPC and PPC64, it used to only be PPC64 (IIRC).
Comment 3 Bastien Nocera 2008-03-04 06:06:21 EST
I'd be happy with the most basic debug for now, the upstream maintainer couldn't
reproduce the bug, and nobody yelled out that it didn't work either.
Comment 4 Bastien Nocera 2008-03-04 06:33:16 EST
I rebuilt sound-juicer, rhythmbox and totem with ExcludeArch for ppc/ppc64.
Comment 5 David Woodhouse 2008-03-07 03:41:30 EST
It's going to be Altivec. We build (for both ppc and ppc64) on machines without
Altivec. GCC 4.3 is probably auto-vectorising something when we don't want it to.
Comment 6 David Woodhouse 2008-03-07 04:31:42 EST
cf. bug #252179
Comment 7 David Woodhouse 2008-03-08 04:57:25 EST
On a machine without Altivec (POWER5) I cannot reproduce. There's more to it
than just gst-inspect-0.10 crashing...

[root@power5 gstreamer-0.10]# rpm -q liboil gstreamer gstreamer-plugins-base
gstreamer-plugins-good
liboil-0.3.13-3.fc9
gstreamer-0.10.17.2-1.fc9
gstreamer-0.10.17.2-1.fc9
gstreamer-plugins-base-0.10.17.2-3.fc9
gstreamer-plugins-good-0.10.7-1.fc9
[root@power5 gstreamer-0.10]# rm -rf ~/.gstreamer-0.10/
[root@power5 gstreamer-0.10]# gst-inspect-0.10
coreindexers:  fileindex: A index that stores entries in file
coreindexers:  memindex: A index that stores entries in memory
coreelements:  multiqueue: MultiQueue
coreelements:  typefind: TypeFind
coreelements:  tee: Tee pipe fitting
coreelements:  filesink: File Sink
coreelements:  queue: Queue
coreelements:  identity: Identity
coreelements:  filesrc: File Source
coreelements:  fdsink: Filedescriptor Sink
coreelements:  fdsrc: Filedescriptor Source
coreelements:  fakesink: Fake Sink
coreelements:  fakesrc: Fake Source
coreelements:  capsfilter: CapsFilter
staticelements:  bin: Generic bin
staticelements:  pipeline: Pipeline object

Total count: 3 plugins, 16 features
Comment 8 Bastien Nocera 2008-03-08 08:43:02 EST
(In reply to comment #7)
> On a machine without Altivec (POWER5) I cannot reproduce. There's more to it
> than just gst-inspect-0.10 crashing...
> 
> [root@power5 gstreamer-0.10]# rpm -q liboil gstreamer gstreamer-plugins-base
> gstreamer-plugins-good
> liboil-0.3.13-3.fc9
> gstreamer-0.10.17.2-1.fc9
> gstreamer-0.10.17.2-1.fc9
  ^^^^^^^^^^^^^^^^^^^^^^^^^

You have both the PPC and PPC64 versions of gstreamer installed.

> [root@power5 gstreamer-0.10]# gst-inspect-0.10
<snip>
> Total count: 3 plugins, 16 features

Check the arches. A PPC gstreamer binary will only check for the PPC plugins, A
PPC64 gstreamer binary will only check for the PPC64 plugins. Remove the PPC
version of GStreamer, and it should list the PPC64 plugins, not the PPC ones.
Comment 9 David Woodhouse 2008-03-08 12:33:46 EST
I'm only interested in the ppc32 version right now, which is also excluded and
which is easier to debug.
Comment 10 David Woodhouse 2008-03-08 15:22:10 EST
This actually seems to be in libvisual...

Program received signal SIGILL, Illegal instruction.
0x0ead5ae8 in check_os_altivec_support () at lv_cpu.c:166
166                     asm volatile
1: x/i $pc  0xead5ae8 <check_os_altivec_support+88>:    vand    v0,v0,v0
(gdb) bt
#0  0x0ead5ae8 in check_os_altivec_support () at lv_cpu.c:166
#1  0x0ead5bc4 in visual_cpu_initialize () at lv_cpu.c:449
#2  0x0ead0230 in visual_init (argc=0x0, argv=0x0) at lv_libvisual.c:315
Comment 11 David Woodhouse 2008-03-08 15:23:34 EST
(gdb) disp/i $pc
2: x/i $pc  0xead5ae8 <check_os_altivec_support+88>:    vand    v0,v0,v0
(gdb) si

0:01:27.146270000  8208 0x10019460 ERROR             GST_INIT
gst.c:853:ensure_current_registry_forking: child did not exit normally,
terminated by signal
Error initializing: Error re-scanning registry , child terminated by signal
Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
Comment 12 David Woodhouse 2008-03-08 15:47:18 EST
Hm. Testing libvisual on its own, however, seems to show that it manages to
catch SIGILL correctly and detect that Altivec isn't present. This seems to be
some interaction between libvisual's Altivec detection and something else;
probably liboil's Altivec detection.
Comment 13 David Woodhouse 2008-03-08 15:56:15 EST
It seems that after liboil is done with checking for Altivec, it leaves SIGILL
blocked...
Comment 14 David Woodhouse 2008-03-08 16:07:56 EST
This works...

int main(void)
{
        visual_cpu_initialize();
        oil_init();
        return 0;
}


... and this doesn't...

int main(void)
{
        oil_init();
        visual_cpu_initialize();
       return 0;
}

I blame liboil, for leaving SIGILL blocked.
Comment 15 Bastien Nocera 2008-03-08 21:50:41 EST
Awesome! Thanks very much David for the debugging.

I'll file a bug against liboil, and disable libvisual plugins for now.
Comment 16 Bastien Nocera 2008-03-09 08:09:04 EDT
Filed:
https://bugs.freedesktop.org/show_bug.cgi?id=14914
Comment 17 David Woodhouse 2008-03-09 16:51:35 EDT
This is the version where it calls oil_init() first... note that it (glibc?)
explicitly _blocks_ SIGILL right before it triggers it, and thus dies.

rt_sigaction(SIGILL, {0xfb191d0, [], 0}, {SIG_DFL}, 8) = 0
--- SIGILL (Illegal instruction) @ 0 (0) ---
rt_sigaction(SIGILL, {SIG_DFL}, NULL, 8) = 0
rt_sigaction(SIGILL, {0xfb191d0, [], 0}, {SIG_DFL}, 8) = 0
brk(0)                                  = 0x10012000
brk(0x10033000)                         = 0x10033000
rt_sigaction(SIGILL, {SIG_DFL}, NULL, 8) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xf7ffe000
write(1, "oil_init done. Next visual_cpu_i"..., 42oil_init done. Next
visual_cpu_initialize
) = 42
open("/proc/stat", O_RDONLY)            = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xf7ffd000
read(3, "cpu  363311 18292 63435 51365310"..., 1024) = 1024
read(3, "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "..., 1024) = 279
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0xf7ffd000, 4096)                = 0
rt_sigaction(SIGILL, {0xff6cdd0, [ILL], SA_RESTART}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [ILL], 8) = 0
--- SIGILL (Illegal instruction) @ 0 (0) ---
+++ killed by SIGILL +++
Comment 18 David Woodhouse 2008-03-09 16:53:00 EDT
This is the version where it calls the libvisual code first...

rt_sigaction(SIGILL, {0xff6cdd0, [ILL], SA_RESTART}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
--- SIGILL (Illegal instruction) @ 0 (0) ---
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGILL, {SIG_DFL}, {0xff6cdd0, [ILL], SA_RESTART}, 8) = 0
Comment 19 Dominik 'Rathann' Mierzejewski 2008-03-09 18:56:14 EDT
This affects gnomeradio as well (can't be built without gnome-media-devel).
Comment 20 Jakub Jelinek 2008-03-09 19:53:52 EDT
Can't you build liboil and libvisual twice, once without altivec support, once
with it, stick the altivec-ized libs into */lib*/altivec/lib*.so.* and
non-altivec libs into */lib*/lib*.so.* and just avoid the altivec detection
altogether?  Or, instead of the SIGILL altivec check on Linux search through
/proc/self/auxv, look for AT_HWCAP (0x10) and check if the AT_HWCAP's argument
has altivec bit set (0x10000000)?
Comment 21 David Woodhouse 2008-03-10 22:04:13 EDT
This seems to DTRT on 32-bit and 64-bit machines both with and without
Altivec...  feel free to use it under BSD licence in liboil, LGPLv2 in
libvisual, and in other places as appropriate.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#include <linux/auxvec.h>
#include <asm/cputable.h>

int altivec_available(void)
{
	static int available = -1;
	int new_avail = 0;
	char fname[64];
	unsigned long buf[4];
	ssize_t count;
	pid_t pid;
	int fd, i;
	
	if (available != -1)
		return available;

	pid = getpid();
	snprintf(fname, sizeof(fname)-1, "/proc/%d/auxv", pid);

	fd = open(fname, O_RDONLY);
	if (fd < 0)
		goto out;
 more:
	count = read(fd, buf, sizeof(buf));
	if (count < 0)
		goto out_close;
	
	for (i=0; i < (count / sizeof(unsigned long)); i += 2) {
		if (buf[i] == AT_HWCAP) {
			new_avail = !!(buf[i+1] & PPC_FEATURE_HAS_ALTIVEC);
			goto out_close;
		} else if (buf[i] == AT_NULL) {
			goto out_close;
		}
	}

	if (count == sizeof(buf))
		goto more;
 out_close:
	close(fd);
 out:
	available = new_avail;
	return available;
}
Comment 22 David Woodhouse 2008-03-10 22:07:22 EDT
Hm, changing the 'unsigned long buf[4]' to a larger number (64, perhaps) would
be sensible. I just reduced it for testing purposes.
Comment 23 Bastien Nocera 2008-03-11 09:30:45 EDT
(In reply to comment #21)
> This seems to DTRT on 32-bit and 64-bit machines both with and without
> Altivec...  feel free to use it under BSD licence in liboil, LGPLv2 in
> libvisual, and in other places as appropriate.

That doesn't work on non-Linux though.
Comment 24 Bastien Nocera 2008-03-11 10:30:05 EDT
Never mind, I see there's already a similar detection function for FreeBSD in
the liboil sources.
Comment 25 Matthias Saou 2008-03-12 08:03:25 EDT
I'm still being bitten by this to build pigment too. Bastien : Is the lasted
patch you committed to CVS already applied?
Comment 26 Bastien Nocera 2008-03-12 09:54:59 EDT
There's fixes for liboil, and libvisual already committed. GStreamer
gst-inspect-0.10 still crashes on ppc64, due to a crasher in the audioresample
plugin. I'll be investigating as soon as I manage to get a rawhide PPC64 machine.

See:
http://koji.fedoraproject.org/koji/taskinfo?taskID=511514
Comment 27 Bastien Nocera 2008-03-12 13:05:45 EDT
It's the usual "oil_init() called twice crashes":
#0  0x0000040000467ac8 in .__libc_malloc () from /lib64/libc.so.6
#1  0x0000040001c96000 in .oil_prototype_from_string () from
/usr/lib64/liboil-0.3.so.0
#2  0x0000040001c98c08 in .oil_test_new () from /usr/lib64/liboil-0.3.so.0
#3  0x0000040001c94098 in .oil_class_optimize () from /usr/lib64/liboil-0.3.so.0
#4  0x0000040001c94400 in .oil_optimize_all () from /usr/lib64/liboil-0.3.so.0
#5  0x0000040001c9468c in .oil_init () from /usr/lib64/liboil-0.3.so.0
#6  0x0000040001c43708 in ?? () from /usr/lib64/gstreamer-0.10/libgstvideotestsrc.so
#7  0x00000400000d9db0 in ?? () from /usr/lib64/libgstreamer-0.10.so.0
#8  0x00000400000daec0 in .gst_plugin_load_file () from
/usr/lib64/libgstreamer-0.10.so.0
#9  0x00000400000e4204 in ?? () from /usr/lib64/libgstreamer-0.10.so.0
#10 0x00000400000e4558 in .gst_registry_scan_path () from
/usr/lib64/libgstreamer-0.10.so.0
#11 0x000004000008e128 in ?? () from /usr/lib64/libgstreamer-0.10.so.0
#12 0x000004000008e2f4 in ?? () from /usr/lib64/libgstreamer-0.10.so.0
#13 0x000004000008fb70 in ?? () from /usr/lib64/libgstreamer-0.10.so.0
#14 0x00000400002964c4 in .g_option_context_parse () from /lib64/libglib-2.0.so.0
#15 0x00000000100063a4 in ?? ()
#16 0x00000400003febf8 in .generic_start_main () from /lib64/libc.so.6
#17 0x00000400003fee10 in .__libc_start_main () from /lib64/libc.so.6
#18 0x0000000000000000 in ?? ()

It shouldn't be happening though...
Comment 28 Bastien Nocera 2008-03-12 13:27:18 EDT
Actually, only one oil_init() run needed:
OIL: DEBUG liboiltest.c 399: oil_test_check_impl(): sum of absolute differences
0 for 300 values
OIL: LOG liboilfunction.c 388: oil_class_optimize(): impl rgb2bgr_ppc2 ave=16.8
std=1.15256
OIL: LOG liboilfunction.c 379: oil_class_optimize(): testing impl rgb2bgr_ppc
OIL: LOG liboiltest.c 232: oil_test_check_function(): calling function rgb2bgr_ppc
OIL: LOG liboiltest.c 241: oil_test_check_function():   dest1: 0x00000000 (0)
OIL: LOG liboiltest.c 241: oil_test_check_function():   src1: 0x00000000 (0)
OIL: LOG liboiltest.c 241: oil_test_check_function():   n: 0x00000064 (100)

And the reproducer:

---8<---
#include <liboil/liboil.h>

int main (int argc, char **argv)
{
        oil_debug_set_level (5);
        oil_init();
        return 0;
}
---8<---

rgb2bgr_ppc crashes...
Comment 29 David Woodhouse 2008-03-12 13:45:03 EDT
OIL: DEBUG liboiltest.c 399: oil_test_check_impl(): sum of absolute differences
0 for 300 values
OIL: LOG liboilfunction.c 388: oil_class_optimize(): impl rgb2bgr_ppc2
ave=200.429 std=1.78508
OIL: LOG liboilfunction.c 379: oil_class_optimize(): testing impl rgb2bgr_ppc
OIL: LOG liboiltest.c 232: oil_test_check_function(): calling function rgb2bgr_ppc
OIL: LOG liboiltest.c 241: oil_test_check_function():   dest1: 0x00000000 (0)
OIL: LOG liboiltest.c 241: oil_test_check_function():   src1: 0x00000000 (0)
OIL: LOG liboiltest.c 241: oil_test_check_function():   n: 0x00000064 (100)
thread_get_info_callback: cannot get thread info: generic error
(gdb) bt
#0  test_altivec (ignored=0x3e10) at liboilcpu-powerpc.c:66
#1  0x0000008009a4c910 in ._IO_vfprintf () from /lib64/libc.so.6
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) x/i $pc
0x8009a4c918 <._IO_vfprintf+120>:       lwa     r7,0(r3)
(gdb) p/x $r3
$1 = 0x3e10
(gdb) 

Hm, isn't gdb supposed to be more helpful than this?
Comment 30 Bastien Nocera 2008-03-12 14:15:24 EDT
Filed bug:
https://bugs.freedesktop.org/show_bug.cgi?id=14971
Comment 31 Bastien Nocera 2008-03-12 16:53:18 EDT
Right, worked around in liboil 0.3.13-6. Please rebuild your apps if you used
the ExcludeArch for ppc/ppc64.

I rebuilt totem, rhythmbox, sound-juicer and gnome-media-devel as well.

Closing as upstream.
Comment 32 David Woodhouse 2008-03-12 18:02:24 EDT
gdb is getting on my tits...

0x4000005ddf0 <rgb2bgr_ppc+96>: mtctr   r7
(gdb) 
0x000004000005ddf4      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x100113c0
5: /x $r11 = 0x4000005de80
4: /x $r10 = 0x400000af398
3: /x $r4 = 0x100126dc
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005ddf4 <rgb2bgr_ppc+100>:        lwzu    r10,4(r4)
(gdb) 
0x000004000005ddf8      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x100113c0
5: /x $r11 = 0x4000005de80
4: /x $r10 = 0xda4a846d
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005ddf8 <rgb2bgr_ppc+104>:        rotlwi  r10,r10,16
(gdb) 
0x000004000005ddfc      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x100113c0
5: /x $r11 = 0x4000005de80
4: /x $r10 = 0x846dda4a
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005ddfc <rgb2bgr_ppc+108>:        and     r11,r10,r9
(gdb) 
0x000004000005de00      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x100113c0
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x846dda4a
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de00 <rgb2bgr_ppc+112>:        subf    r10,r11,r10
(gdb) 
0x000004000005de04      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x100113c0
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x8400da00
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de04 <rgb2bgr_ppc+116>:        andi.   r12,r11,255
(gdb) 
0x000004000005de08      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x4a
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x8400da00
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de08 <rgb2bgr_ppc+120>:        rotlwi  r12,r12,16
(gdb) 
0x000004000005de0c      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x4a0000
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x8400da00
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de0c <rgb2bgr_ppc+124>:        or      r10,r10,r12
(gdb) 
0x000004000005de10      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0x4a0000
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x844ada00
3: /x $r4 = 0x100126e0
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de10 <rgb2bgr_ppc+128>:        lwzu    r12,4(r4)
(gdb) 
0x000004000005de14      53        asm volatile (
7: /x $r13 = 0x400000bfc10
6: /x $r12 = 0xa45efafd
5: /x $r11 = 0x6d004a
4: /x $r10 = 0x844ada00
3: /x $r4 = 0x100126e4
2: /x $r3 = 0x1001239c
1: x/i $pc
0x4000005de14 <rgb2bgr_ppc+132>:        and     r13,r12,r8
(gdb) 
thread_get_info_callback: cannot get thread info: generic error
(gdb) 
thread_get_info_callback: cannot get thread info: generic error
(gdb) x/i $pc
0x4000005de1c <rgb2bgr_ppc+140>:        rotlwi  r13,r13,16
(gdb) x/i $pc-4
0x4000005de18 <rgb2bgr_ppc+136>:        subf    r12,r13,r12
(gdb) 

Comment 33 David Woodhouse 2008-03-12 18:06:06 EDT
Oh, r13 is the TLS register in ppc64. Use a different register, and it should be
fine.
Comment 34 David Woodhouse 2008-03-12 18:38:40 EDT
Created attachment 297860 [details]
patch to use a different register

Note You need to log in before you can comment on or make changes to this bug.