NetBSD Problem Report #50386

From www@NetBSD.org  Sat Oct 31 22:43:10 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6FA46A57FE
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 31 Oct 2015 22:43:10 +0000 (UTC)
Message-Id: <20151031224309.13B49A6558@mollari.NetBSD.org>
Date: Sat, 31 Oct 2015 22:43:09 +0000 (UTC)
From: okuyama@flex.phys.tohoku.ac.jp
Reply-To: okuyama@flex.phys.tohoku.ac.jp
To: gnats-bugs@NetBSD.org
Subject: xterm on m68k broken due to libX11
X-Send-Pr-Version: www-1.0

>Number:         50386
>Category:       xsrc
>Synopsis:       xterm on m68k broken due to libX11
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 31 22:45:00 +0000 2015
>Closed-Date:    Sat Dec 26 22:21:34 +0000 2015
>Last-Modified:  Sat Dec 26 22:25:01 +0000 2015
>Originator:     Rin Okuyama
>Release:        7.99.21 and 7.0
>Organization:
Department of Physics, Tohoku University
>Environment:
NetBSD x68k 7.99.21 NetBSD 7.99.21 (GENERIC) #0: Sun Nov  1 01:54:13 JST 2015  root@XXX:/var/build/obj/m68k/sys/arch/x68k/compile/GENERIC x68k
>Description:
On NetBSD/x68k 7.99.21, xterm(1) starts up, and it echoes back keyboard
input. However, shell is not invoked:
  https://twitter.com/LabDrunker/status/660584606123462656

tsutsui@ and isaki@ told me that they observed same phenomenon in
NetBSD 7.0 release on luna68k and x68k, respectively.

Here is output of ps(1) on remote console:
> x68k% ps
> PID TTY   STAT    TIME COMMAND
> 2765 pts/0 S    0:00.94 -ksh
> 3348 pts/0 O+   0:00.43 ps
> 167 ttye0 Z    0:00.00 (xterm)
> 174 ttye0 I    0:10.64 xterm
> 1042 ttye0 I    0:01.09 -ksh
> 3421 ttye0 I+   0:02.62 xinit

You can see a child process of xterm(1) became a zombie before executing
shell.

When libc is replaced by that built with "DBG=-O1", shell succeeds to
run on xterm(1):
  https://twitter.com/LabDrunker/status/660584995619147776

These facts indicate that O2-level optimization of gcc-4.8.[45] is
broken on m68k.
>How-To-Repeat:
Run xterm(1) on NetBSD/m68k 7.99.21 or 7.0.
>Fix:
N/A

>Release-Note:

>Audit-Trail:
From: Rin Okuyama <okuyama@flex.phys.tohoku.ac.jp>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-m68k/50386: O2-level optimization of gcc 4.8.4/4.8.5 broken
 on m68k
Date: Sat, 7 Nov 2015 17:04:40 +0900

 I've found that arc4random.o is broken with -O2 flag. A child process of
 xterm(1) becomes a zombie through following scenario.

 xterm(1) creates a temporary directory by mkdtemp(3), which calls
 arc4random_uniform(3) internally. As arc4random.o is broken, the caller
 receives a bogus file name. You can confirm this by looking at /var/tmp
 or $TMPDIR after killing xterm(1).

 Moreover, arc4random_uniform(3) registers fork handlers by
 pthread_atfork(3). A child process of xterm(1), therefore, calls the
 broken handler to become a zombie.

 I've confirmed this scenario with the use of gdb(1). Actually, xterm(1)
 works fine with libc built with the attached patch, by that only
 arc4random.c is compiled with -O1 flag.

 At this moment, I've not understood conditions by which arc4random*(3)
 becomes strange. For example, mktemp(1) seems to work fine even with
 broken libc. However, at least, xterm(1) never works with it.

 --- src/lib/libc/gen/Makefile.inc.orig	2015-11-07 15:15:29.000000000 +0900
 +++ src/lib/libc/gen/Makefile.inc	2015-11-07 15:25:18.000000000 +0900
 @@ -199,3 +199,8 @@
  	${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}

  CLEANFILES+= errlist.c
 +
 +.if ${MACHINE_ARCH} == "m68k"
 +# XXX work around a gcc 4.8.x bug
 +COPTS.arc4random.c=	-O1
 +.endif

Responsible-Changed-From-To: port-m68k-maintainer->xsrc-manager
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Tue, 10 Nov 2015 03:08:34 +0000
Responsible-Changed-Why:
By submitter request.
Also, synopsis changed from:
O2-level optimization of gcc 4.8.4/4.8.5 broken on m68k

The problem is that xterm does not work on m68k. Some circumstantial
evidences indicate that the origin of problem is optimization error
in gcc. However, in the discussion at port-m68k, mlelstv@ revealed
that the real cause of the problem is not gcc, but libX11:

  http://mail-index.netbsd.org/port-m68k/2015/11/09/msg000648.html


From: Rin Okuyama <okuyama@flex.phys.tohoku.ac.jp>
To: gnats-bugs@NetBSD.org
Cc: port-m68k@netbsd.org
Subject: Re: xsrc/50386 (xterm on m68k broken due to libX11)
Date: Tue, 10 Nov 2015 13:15:03 +0900

 The cause of the problem is that libX11 poisons namespace of libc, by
 shading the original stubs for thread operations by broken ones with
 inappropriate prototype. You can find more details in an outstanding
 analysis given by mlelstv@:

   http://mail-index.netbsd.org/port-m68k/2015/11/09/msg000647.html

 The broken stubs are provided in
 xsrc/external/mit/libX11/dist/src/UIThrStubs.c. As we already have our
 own stubs in libc below src/lib/libc/thread-stub, I think we no longer
 need them in libX11.

 Looking into autoconf stuffs of libX11, UIThrStubs.c is intended to be
 compiled if stub for pthread_self(3) is missing in libc. Actually, we
 don't have it in libc; UIThrStubs.c provides stubs for more thread
 operations than our libc does. However, if we need them, they should be
 provided by libc, not libX11.

 The attached patch below simply removes UIThrStubs.c from libX11. xterm
 gets sanity with this patch on x68k. I also checked X server and few X
 clients work fine with this patch on x68k, evbearmv7hfeb, and amd64.
 However, I've not confirmed whether most other 3rd-party applications
 work or not.

 --- src/external/mit/xorg/lib/libX11/Makefile.libx11.orig	2015-11-09 19:43:39.000000000 +0900
 +++ src/external/mit/xorg/lib/libX11/Makefile.libx11	2015-11-09 19:47:04.000000000 +0900
 @@ -265,8 +265,8 @@
  	XlibInt.c \
  	Xrm.c

 -SRCS+=	\
 -	UIThrStubs.c 
 +#SRCS+=	\
 +#	UIThrStubs.c 

  SRCS+=	\
  	AddDIC.c \

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: port-m68k@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: xsrc/50386 (xterm on m68k broken due to libX11)
Date: Sun, 15 Nov 2015 00:00:22 +0900

 > --- src/external/mit/xorg/lib/libX11/Makefile.libx11.orig	2015-11-09 19:43:39.000000000 +0900
 > +++ src/external/mit/xorg/lib/libX11/Makefile.libx11	2015-11-09 19:47:04.000000000 +0900
 > @@ -265,8 +265,8 @@
 >  	XlibInt.c \
 >  	Xrm.c
 >  
 > -SRCS+=	\
 > -	UIThrStubs.c 
 > +#SRCS+=	\
 > +#	UIThrStubs.c 
 >  
 >  SRCS+=	\
 >  	AddDIC.c \

 I've also confirmed this fixes the problem (shell in xterm doesn't start)
 on NetBSD/luna68k 7.0 and NetBSD/x68k 7.0.

 If no other developer handles this matter, I'll commit it to see
 if it could cause any other unexpected side effect on the HEAD.

 ---
 Izumi Tsutsui

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: xsrc-manager@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, okuyama@flex.phys.tohoku.ac.jp
Subject: re: xsrc/50386 (xterm on m68k broken due to libX11)
Date: Sun, 15 Nov 2015 07:37:29 +1100

 > =

 >  > --- src/external/mit/xorg/lib/libX11/Makefile.libx11.orig	2015-11-09 =
 19:43:39.000000000 +0900
 >  > +++ src/external/mit/xorg/lib/libX11/Makefile.libx11	2015-11-09 19:47=
 :04.000000000 +0900
 >  > @@ -265,8 +265,8 @@
 >  >  	XlibInt.c \
 >  >  	Xrm.c
 >  >  =

 >  > -SRCS+=3D	\
 >  > -	UIThrStubs.c =

 >  > +#SRCS+=3D	\
 >  > +#	UIThrStubs.c =

 >  >  =

 >  >  SRCS+=3D	\
 >  >  	AddDIC.c \
 >  =

 >  I've also confirmed this fixes the problem (shell in xterm doesn't star=
 t)
 >  on NetBSD/luna68k 7.0 and NetBSD/x68k 7.0.
 >  =

 >  If no other developer handles this matter, I'll commit it to see
 >  if it could cause any other unexpected side effect on the HEAD.

 ah, i thought i commited this -- but apparently i only tested it
 (on amd64).

 please feel free to commit and request pullups.

 thanks!

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50386 CVS commit: src/external/mit/xorg/lib/libX11
Date: Sat, 21 Nov 2015 11:15:31 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sat Nov 21 11:15:31 UTC 2015

 Modified Files:
 	src/external/mit/xorg/lib/libX11: Makefile.libx11

 Log Message:
 Disable UIThrStubs.c, which is unnecessary on NetBSD.

 This fixes xterm startup failure on NetBSD/m68k 7.0.
 See PR/50386 for details.

 Should be pulled up to netbsd-7 and netbsd-7-0.


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 src/external/mit/xorg/lib/libX11/Makefile.libx11

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: xsrc-manager->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sun, 22 Nov 2015 06:00:32 +0000
Responsible-Changed-Why:
committed by myself


State-Changed-From-To: open->analyzed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 22 Nov 2015 06:00:32 +0000
State-Changed-Why:
Pullup request will be sent after it's confirmed that
there is no other bad side effect.


From: Rin Okuyama <okuyama@flex.phys.tohoku.ac.jp>
To: gnats-bugs@NetBSD.org, tsutsui@netbsd.org
Cc: 
Subject: Re: PR/50386 CVS commit: src/external/mit/xorg/lib/libX11
Date: Thu, 26 Nov 2015 19:54:12 +0900

 Thank you for your commitment. I'm testing whether there are some side
 effects or not. I'm using two environments regularly, that is,

 (1) NetBSD/amd64-current and pkgsrc-current
 (2) NetBSD/amd64 7-stable with libX11 back-ported from current, and binary
 packages from pkgsrc-2015Q3 for NetBSD/amd64 7.0

 Until today, there is no trouble with my daily usage of X11 applications
 (this is far away of comprehensive nor systematic test, although). I will
 report here if I encounter some problems.

 Thanks,
 Rin

State-Changed-From-To: analyzed->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 28 Nov 2015 05:55:54 +0000
State-Changed-Why:
[pullup-7 #1052]


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50386 CVS commit: [netbsd-7] src/external/mit/xorg/lib/libX11
Date: Sat, 26 Dec 2015 22:18:57 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Dec 26 22:18:57 UTC 2015

 Modified Files:
 	src/external/mit/xorg/lib/libX11 [netbsd-7]: Makefile.libx11

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1052):
 	external/mit/xorg/lib/libX11/Makefile.libx11: revision 1.17
 Disable UIThrStubs.c, which is unnecessary on NetBSD.
 This fixes xterm startup failure on NetBSD/m68k 7.0.
 See PR/50386 for details.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.13.2.1 \
     src/external/mit/xorg/lib/libX11/Makefile.libx11

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: snj@NetBSD.org
State-Changed-When: Sat, 26 Dec 2015 22:21:34 +0000
State-Changed-Why:
Pulled up.


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50386 CVS commit: [netbsd-7-0] src/external/mit/xorg/lib/libX11
Date: Sat, 26 Dec 2015 22:20:03 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Dec 26 22:20:03 UTC 2015

 Modified Files:
 	src/external/mit/xorg/lib/libX11 [netbsd-7-0]: Makefile.libx11

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1052):
 	external/mit/xorg/lib/libX11/Makefile.libx11: revision 1.17
 Disable UIThrStubs.c, which is unnecessary on NetBSD.
 This fixes xterm startup failure on NetBSD/m68k 7.0.
 See PR/50386 for details.
 Should be pulled up to netbsd-7 and netbsd-7-0.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.13.4.1 \
     src/external/mit/xorg/lib/libX11/Makefile.libx11

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.