Subject: lib/20519: sigsuspend in libpthread is broken
To: None <gnats-bugs@gnats.netbsd.org>
From: None <toshii@netbsd.org>
List: netbsd-bugs
Date: 02/28/2003 16:10:47
>Number:         20519
>Category:       lib
>Synopsis:       sigsuspend in libpthread is broken
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 27 23:11:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     IWAMOTO Toshihiro
>Release:        NetBSD 1.6P
>Organization:
	
>Environment:
System: NetBSD pepper.my.domain 1.6P NetBSD 1.6P (PEPPER) #126: Fri Feb 28 11:48:07 JST 2003 root@pepper.my.domain:/sys/arch/i386/compile/PEPPER i386
Architecture: i386
Machine: i386
>Description:
	libpthread's sigsuspend doesn't work if there is no other thread.
	Because of this, mplayer -tv does no longer work.
	For those who don't know how apps that use bktr(4) work,
	bktr(4) sends a signal when a frame capture is complete, and the
	apps often use sigsuspend to wait the signal.
	
>How-To-Repeat:
	Try "mplayer -tv ..." (detail shown below), or the following test
	program.

	$ cat a.c
	#include <signal.h>

	int
	main() {
		sigset_t set;

		sigemptyset(&set);
		sigaddset(&set, SIGUSR1);

		sigsuspend(&set);
	}
	$ cc a.c -lpthread
	$ ./a.out
	assertion "next != 0" failed: file "/usr/src/lib/libpthread/pthread_run.c", line 115, function "pthread__next"
	Abort trap (core dumped)

	$ gdb mplayer
	GNU gdb 5.0nb1
	Copyright 2000 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--netbsdelf"...(no debugging symbols found)...
	(gdb) handle SIGUSR1 pass noprint nostop
	Signal        Stop      Print   Pass to program Description
	SIGUSR1       No        No      Yes             User defined signal 1
	(gdb) run -tv on:driver=bsdbt848:norm=ntsc:input=0:chanlist=japan-bcast:noaudio
	Starting program: /usr/pkg/bin/mplayer -tv on:driver=bsdbt848:norm=ntsc:input=0:chanlist=japan-bcast:noaudio
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	(no debugging symbols found)...(no debugging symbols found)...
	Using GNU internationalization
	Original domain: messages
	Current domain: mplayer


	MPlayer 0.90rc4-2.95.3 (C) 2000-2003 Arpad Gereoffy (see DOCS)

	CPU: Advanced Micro Devices Athlon 4 PM Palomino/Athlon MP Multiprocessor/Athlon XP eXtreme Performance (Family: 6, Stepping: 2)
	Detected cache-line size is 64 bytes
	CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
	Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE

	Reading config file /usr/pkg/share/mplayer/mplayer.conf: No such file or directory
	Reading config file /home/toshii/.mplayer/config
	Reading /home/toshii/.mplayer/codecs.conf: can't open '/home/toshii/.mplayer/codecs.conf': No such file or directory
	Reading /usr/pkg/share/mplayer/codecs.conf: 50 audio & 135 video codecs
	font: can't open file: /home/toshii/.mplayer/font/font.desc
	Font /usr/pkg/share/mplayer/font/font.desc loaded successfully! (206 chars)
	Using usleep() timing
	Can't open input config file /home/toshii/.mplayer/input.conf : No such file or directory
	Input config file /usr/pkg/share/mplayer/input.conf parsed : 52 binds

	Playing TV
	TV detected! ;-)
	Selected driver: bsdbt848
	 name: Brooktree848 Support
	 author: Charles Henrich
	 comment: in development
	/dev/dsp open: No such file or directory
	setfrag: Bad file descriptor
	START
	vo: X11 running at 1280x1024 with depth 24 and 32 bpp (":0" => local display)
	==========================================================================
	Opening video decoder: [raw] RAW Uncompressed Video
	VDec: vo config request - 640 x 480 (preferred csp: Packed UYVY)
	VDec: using Packed UYVY as output csp (no 0)
	Movie-Aspect is undefined - no prescaling applied.
	VO: [xmga] 640x480 => 640x480 Packed UYVY
	[mga] Using 3 buffers.
	Selected video codec: [rawuyvy] vfm:raw (RAW UYVY)
	==========================================================================
	Audio: no sound
	Starting playback...
	assertion "next != 0" failed: file "/usr/src/lib/libpthread/pthread_run.c", line 115, function "pthread__next"
	(no debugging symbols found)...(no debugging symbols found)...
	Program received signal SIGABRT, Aborted.
	0x487203ef in kill () from /usr/lib/libc.so.12
	(gdb) inf st
	#0  0x487203ef in kill () from /usr/lib/libc.so.12
	#1  0xdac3815b in ?? ()
	#2  0x4855a6d0 in pthread__next () from /usr/lib/libpthread.so.0
	#3  0x4855a60b in pthread__block () from /usr/lib/libpthread.so.0
	#4  0x485576bd in __sigsuspend14 () from /usr/lib/libpthread.so.0
	#5  0x8131668 in tvi_init_dummy ()
	Error accessing memory address 0x96000: Invalid argument.
	(gdb) thre ex all
	0xbfbc0000: thread    0 sleeping on cond var at 0x485609c8
	(gdb) kill
	Kill the program being debugged? (y or n) y

>Fix:
	No idea. (I don't want to know libpthread internal right now. ;-)
>Release-Note:
>Audit-Trail:
>Unformatted: