NetBSD Problem Report #53229

From martin@aprisoft.de  Sun Apr 29 08:28:40 2018
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 1923B7A261
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 29 Apr 2018 08:28:40 +0000 (UTC)
Message-Id: <20180429082827.679305CC850@emmas.aprisoft.de>
Date: Sun, 29 Apr 2018 10:28:27 +0200 (CEST)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: textproc/py-expat does not build w/o terminal session
X-Send-Pr-Version: 3.95

>Number:         53229
>Category:       pkg
>Synopsis:       textproc/py-expat does not build w/o terminal session
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    leot
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 29 08:30:00 +0000 2018
>Closed-Date:    Sun May 05 09:46:00 +0000 2019
>Last-Modified:  Sun May 05 09:46:00 +0000 2019
>Originator:     Martin Husemann
>Release:        NetBSD 8.99.14
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD seven-days-to-the-wolves.aprisoft.de 8.99.14 NetBSD 8.99.14 (GENERIC) #213: Sat Apr 28 09:26:35 CEST 2018 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

Trying to build textproc/py-expat w/o a terminal session failse.

Doing it in a regular shell works fine:

=> Bootstrap dependency digest>=20010302: found digest-20160304
WARNING: [license.mk] Every package should define a LICENSE.
===> Skipping vulnerability checks.
WARNING: No /var/db/pkg/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/sbin/pkg_admin -K /var/db/pkg fetch-pkg-vulnerabilities'.
===> Building for py36-expat-3.6.5
(cd /work/pkgobj/textproc/py-expat/work/Python-3.6.5/ && /usr/bin/env USETOOLS=no PTHREAD_CFLAGS=\ -pthread\  PTHREAD_LDFLAGS=\ -pthread PTHREAD_LIBS= PTHREADBASE=/usr DL_CFLAGS=\ -pthread\  DL_LDFLAGS=\ -pthread DL_LIBS= PYTHON=/usr/pkg/bin/python3.6 CC=gcc CFLAGS=-O2\ -pipe\ -D_FORTIFY_SOURCE=2\ -I/usr/include\ -I/usr/pkg/include/python3.6 CPPFLAGS=-I/usr/include\ -I/usr/pkg/include/python3.6 CXX=c++ CXXFLAGS=-O2\ -pipe\ -D_FORTIFY_SOURCE=2\ -I/usr/include\ -I/usr/pkg/include/python3.6 COMPILER_RPATH_FLAG=-Wl,-R F77=g77 FC=g77 FFLAGS=-O LANG=C LC_ALL=C LC_COLLATE=C LC_CTYPE=C LC_MESSAGES=C LC_MONETARY=C LC_NUMERIC=C LC_TIME=C LDFLAGS=-L/usr/lib\ -Wl,-R/usr/lib\ -Wl,-R/usr/pkg/lib LINKER_RPATH_FLAG=-R PATH=/work/pkgobj/textproc/py-expat/work/.cwrapper/bin:/work/pkgobj/textproc/py-expat/work/.buildlink/bin:/work/pkgobj/textproc/py-expat/work/.gcc/bin:/work/pkgobj/textproc/py-expat/work/.tools/bin:/usr/pkg/bin:/root/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11
 R7/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/pkg/bin:/usr/X11R7/bin PREFIX=/usr/pkg MAKELEVEL=0 CONFIG_SITE= PKG_SYSCONFDIR=/usr/pkg/etc CXXCPP=cpp HOME=/work/pkgobj/textproc/py-expat/work/.home CWRAPPERS_CONFIG_DIR=/work/pkgobj/textproc/py-expat/work/.cwrapper/config CPP=cpp LOCALBASE=/usr/pkg X11BASE=/usr/X11R7 PKGMANDIR=man PKGINFODIR=info PKGGNUDIR=gnu/ MAKECONF=/dev/null OBJECT_FMT=ELF USETOOLS=no BSD_INSTALL_PROGRAM=/usr/bin/install\ -c\ -s\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_SCRIPT=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_LIB=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_DATA=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 644 BSD_INSTALL_MAN=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 644 BSD_INSTALL=/usr/bin/install BSD_INSTALL_PROGRAM_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_SCRIPT_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_LIB_DIR=/usr/bin/install\ -d\ -o\ root\ -
 g\ wheel\ -m\ 755 BSD_INSTALL_DATA_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_MAN_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_GAME=/usr/bin/install\ -c\ -s\ -o\ root\ -g\ wheel\ -m\ 2555 BSD_INSTALL_GAME_DATA=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 664 BSD_INSTALL_GAME_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 775 INSTALL_INFO= MAKEINFO=/work/pkgobj/textproc/py-expat/work/.tools/bin/makeinfo FLEX= BISON= PKG_CONFIG= PKG_CONFIG_LIBDIR=/work/pkgobj/textproc/py-expat/work/.buildlink/lib/pkgconfig:/work/pkgobj/textproc/py-expat/work/.buildlink/share/pkgconfig PKG_CONFIG_LOG=/work/pkgobj/textproc/py-expat/work/.pkg-config.log PKG_CONFIG_PATH= CWRAPPERS_CONFIG_DIR=/work/pkgobj/textproc/py-expat/work/.cwrapper/config /usr/pkg/bin/python3.6  setup.py  build )
running build
running build_ext
building 'pyexpat' extension
creating build
creating build/temp.netbsd-8.99.14-amd64-3.6
creating build/temp.netbsd-8.99.14-amd64-3.6/Modules
gcc -DNDEBUG -O2 -pipe -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/pkg/include -O2 -pipe -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/include -I/usr/pkg/include/python3.6 -fPIC -DHAVE_EXPAT_H -I/work/pkgobj/textproc/py-expat/work/.buildlink/include -I/usr/pkg/include/python3.6 -c Modules/pyexpat.c -o build/temp.netbsd-8.99.14-amd64-3.6/Modules/pyexpat.o
creating build/lib.netbsd-8.99.14-amd64-3.6
gcc -pthread -shared -L. -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -O2 -pipe -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/include -I/usr/pkg/include/python3.6 build/temp.netbsd-8.99.14-amd64-3.6/Modules/pyexpat.o -L/work/pkgobj/textproc/py-expat/work/.buildlink/lib -L/usr/pkg/lib -Wl,-R/work/pkgobj/textproc/py-expat/work/.buildlink/lib -lexpat -lpython3.6 -o build/lib.netbsd-8.99.14-amd64-3.6/pyexpat.so



But if you start a background job to build it and disconnect from the
terminal, it fails:

Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x000075b4e4cee800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007b9cf4e33800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x0000718542489800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
=> Bootstrap dependency digest>=20010302: found digest-20160304
WARNING: [license.mk] Every package should define a LICENSE.
===> Skipping vulnerability checks.
WARNING: No /var/db/pkg/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/sbin/pkg_admin -K /var/db/pkg fetch-pkg-vulnerabilities'.
=> Checksum SHA1 OK for Python-3.6.5.tar.xz
=> Checksum RMD160 OK for Python-3.6.5.tar.xz
=> Checksum SHA512 OK for Python-3.6.5.tar.xz
===> Installing dependencies for py36-expat-3.6.5
==========================================================================
The following variables will affect the build process of this package,
py36-expat-3.6.5.  Their current value is shown below:

        * PYTHON_VERSION_DEFAULT = 36

Based on these variables, the following variables have been set:

        * PYPACKAGE = python36

You may want to abort the process now with CTRL-C and change their value
before continuing.  Be sure to run `/usr/bin/make clean' after
the changes.
==========================================================================
=> Tool dependency checkperms>=1.1: found checkperms-1.12
=> Build dependency cwrappers>=20150314: found cwrappers-20180325
=> Full dependency python36>=3.6.0: found python36-3.6.5
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007672eac21800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007b4597990800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x000077e9ca073800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
===> Overriding tools for py36-expat-3.6.5
===> Extracting for py36-expat-3.6.5
/usr/bin/sed  -e s!@EXPATPREFIX@!/work/pkgobj/textproc/py-expat/work/.buildlink!g  -e s!@EXPATRTPREFIX@!/usr!g  </usr/pkgsrc/textproc/py-expat/files/setup.py >/work/pkgobj/textproc/py-expat/work/Python-3.6.5/setup.py
===> Patching for py36-expat-3.6.5
(cd /work/pkgobj/textproc/py-expat/work/Python-3.6.5;  for f in /usr/pkgsrc/textproc/py-expat/../../lang/python36/patches/patch-*;do  /usr/bin/patch --batch <$f || true;  done)
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Lib_distutils_command_install.py,v 1.1 2017/01/01 14:34:27 adam Exp $
|
|--- Lib/distutils/command/install.py.orig	2016-12-23 02:21:19.000000000 +0000
|+++ Lib/distutils/command/install.py
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 652.
1 out of 1 hunks ignored--saving rejects to install.py.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Lib_distutils_sysconfig.py,v 1.2 2017/01/26 09:13:27 adam Exp $
|
|Remove _multiarch from config path (differs across platforms).
|Simplify _sysconfigdata to include only platform name.
|
|--- Lib/distutils/sysconfig.py.orig	2016-12-23 02:21:19.000000000 +0000
|+++ Lib/distutils/sysconfig.py
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 242.
Hunk #2 ignored at 417.
2 out of 2 hunks ignored--saving rejects to sysconfig.py.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Lib_distutils_unixccompiler.py,v 1.1 2017/01/01 14:34:27 adam Exp $
|
|Do not force RUNPATH vs RPATH, trust the compiler to know what the
|platform wants.
|
|--- Lib/distutils/unixccompiler.py.orig	2016-12-23 02:21:19.000000000 +0000
|+++ Lib/distutils/unixccompiler.py
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 236.
1 out of 1 hunks ignored--saving rejects to unixccompiler.py.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Lib_sysconfig.py,v 1.2 2017/01/26 09:13:27 adam Exp $
|
|Remove _multiarch from config path (differs across platforms).
|Simplify _sysconfigdata to include only platform name.
|
|--- Lib/sysconfig.py.orig	2016-12-23 02:21:19.000000000 +0000
|+++ Lib/sysconfig.py
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 337.
1 out of 1 hunks ignored--saving rejects to sysconfig.py.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Makefile.pre.in,v 1.5 2017/12/19 09:37:14 adam Exp $
|
|Use only one optimisation level; needed for PLIST and setuptools compatibility.
|Do not build/install libpython3.so.
|Simplify _sysconfigdata to include only platform name.
|Swap targets libinstall and libainstall, to byte-compile python-config.py.
|
|--- Makefile.pre.in.orig	2017-12-19 04:53:56.000000000 +0000
|+++ Makefile.pre.in
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 96.
Hunk #2 ignored at 207.
Hunk #3 ignored at 432.
Hunk #4 ignored at 886.
Hunk #5 ignored at 894.
Hunk #6 ignored at 1101.
Hunk #7 ignored at 1160.
Hunk #8 ignored at 1338.
Hunk #9 ignored at 1356.
Hunk #10 ignored at 1364.
Hunk #11 ignored at 1464.
11 out of 11 hunks ignored--saving rejects to Makefile.pre.in.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Modules_makesetup,v 1.1 2017/01/01 14:34:27 adam Exp $
|
|Support -pthread compiler flag.
|http://bugs.python.org/issue21461
|
|--- Modules/makesetup.orig	2008-06-11 05:26:20.000000000 +0000
|+++ Modules/makesetup
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 166.
1 out of 1 hunks ignored--saving rejects to Modules/makesetup.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Modules_nismodule.c,v 1.1 2017/01/01 14:34:27 adam Exp $
|
|DragonFlyBSD support
|http://bugs.python.org/issue21459
|
|--- Modules/nismodule.c.orig	2010-08-19 09:03:03.000000000 +0000
|+++ Modules/nismodule.c
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 85.
1 out of 1 hunks ignored--saving rejects to Modules/nismodule.c.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Modules_socketmodule.c,v 1.2 2017/12/19 09:37:14 adam Exp $
|
|Support NetBSD's socketcan implementation
|
|--- Modules/socketmodule.c.orig	2017-12-19 04:53:56.000000000 +0000
|+++ Modules/socketmodule.c
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 1375.
Hunk #2 ignored at 1883.
Hunk #3 ignored at 1910.
Hunk #4 ignored at 7123.
4 out of 4 hunks ignored--saving rejects to Modules/socketmodule.c.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Modules_socketmodule.h,v 1.1 2017/05/30 13:36:39 bouyer Exp $
|
|--- Modules/socketmodule.h.orig	2017-03-21 07:32:38.000000000 +0100
|+++ Modules/socketmodule.h	2017-05-30 12:36:59.254776235 +0200
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 91.
1 out of 1 hunks ignored--saving rejects to Modules/socketmodule.h.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-Python_thread__pthread.h,v 1.1 2017/01/01 14:34:27 adam Exp $
|
|--- Python/thread_pthread.h.orig	2013-05-15 16:33:00.000000000 +0000
|+++ Python/thread_pthread.h
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 50.
1 out of 1 hunks ignored--saving rejects to thread_pthread.h.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-configure,v 1.10 2017/07/18 13:43:40 adam Exp $
|
|Simplify _sysconfigdata to include only platform name.
|
|MirBSD support
|http://bugs.python.org/issue21458
|
|Changes for consistency across pkgsrc platforms.
|
|Fix linking on Darwin.
|
|Use gnu99 instead of c99 to avoid "alloca() undefined" problems on macppc.
|
|detect netcan/can.h on NetBSD
|
|--- configure.orig	2017-07-08 03:33:27.000000000 +0000
|+++ configure
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 2925.
Hunk #2 ignored at 3317.
Hunk #3 ignored at 5962.
Hunk #4 ignored at 6937.
Hunk #5 ignored at 8112.
Hunk #6 ignored at 9228.
Hunk #7 ignored at 9253.
Hunk #8 ignored at 9294.
Hunk #9 ignored at 9341.
Hunk #10 ignored at 9391.
Hunk #11 ignored at 11168.
Hunk #12 ignored at 14995.
Hunk #13 ignored at 15006.
13 out of 13 hunks ignored--saving rejects to configure.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-pyconfig.h.in,v 1.1 2017/05/30 13:36:39 bouyer Exp $
|
|detect netcan/can.h on NetBSD
|
|--- pyconfig.h.in.orig	2017-05-30 12:31:24.586818399 +0200
|+++ pyconfig.h.in	2017-05-30 12:32:29.367288479 +0200
--------------------------
No file to patch.  Skipping...
Hunk #1 ignored at 565.
1 out of 1 hunks ignored--saving rejects to pyconfig.h.in.rej
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|$NetBSD: patch-setup.py,v 1.4 2017/12/19 09:37:14 adam Exp $
|
|Disable modules, so they can be built as separate packages.
|
|--- setup.py.orig	2017-12-19 04:53:56.000000000 +0000
|+++ setup.py
--------------------------
Patching file setup.py using Plan A...
Hunk #1 failed at 8.
No such line 42 in input file, ignoring
Hunk #2 failed at 44.
Hunk #3 failed at 514.
Hunk #4 failed at 844.
Hunk #5 failed at 855.
Hunk #6 failed at 874.
Hunk #7 failed at 1274.
Hunk #8 failed at 1309.
Hunk #9 failed at 2128.
Hunk #10 failed at 2365.
10 out of 10 hunks failed--saving rejects to setup.py.rej
done
===> Creating toolchain wrappers for py36-expat-3.6.5
===> Configuring for py36-expat-3.6.5
=> Checking for portability problems in extracted files
===> Building for py36-expat-3.6.5
(cd /work/pkgobj/textproc/py-expat/work/Python-3.6.5/ && /usr/bin/env USETOOLS=no PTHREAD_CFLAGS=\ -pthread\  PTHREAD_LDFLAGS=\ -pthread PTHREAD_LIBS= PTHREADBASE=/usr DL_CFLAGS=\ -pthread\  DL_LDFLAGS=\ -pthread DL_LIBS= PYTHON=/usr/pkg/bin/python3.6 CC=gcc CFLAGS=-O2\ -pipe\ -D_FORTIFY_SOURCE=2\ -I/usr/include\ -I/usr/pkg/include/python3.6 CPPFLAGS=-I/usr/include\ -I/usr/pkg/include/python3.6 CXX=c++ CXXFLAGS=-O2\ -pipe\ -D_FORTIFY_SOURCE=2\ -I/usr/include\ -I/usr/pkg/include/python3.6 COMPILER_RPATH_FLAG=-Wl,-R F77=g77 FC=g77 FFLAGS=-O LANG=C LC_ALL=C LC_COLLATE=C LC_CTYPE=C LC_MESSAGES=C LC_MONETARY=C LC_NUMERIC=C LC_TIME=C LDFLAGS=-L/usr/lib\ -Wl,-R/usr/lib\ -Wl,-R/usr/pkg/lib LINKER_RPATH_FLAG=-R PATH=/work/pkgobj/textproc/py-expat/work/.cwrapper/bin:/work/pkgobj/textproc/py-expat/work/.buildlink/bin:/work/pkgobj/textproc/py-expat/work/.gcc/bin:/work/pkgobj/textproc/py-expat/work/.tools/bin:/usr/pkg/bin:/root/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11
 R7/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/pkg/bin:/usr/X11R7/bin PREFIX=/usr/pkg MAKELEVEL=0 CONFIG_SITE= PKG_SYSCONFDIR=/usr/pkg/etc CXXCPP=cpp HOME=/work/pkgobj/textproc/py-expat/work/.home CWRAPPERS_CONFIG_DIR=/work/pkgobj/textproc/py-expat/work/.cwrapper/config CPP=cpp LOCALBASE=/usr/pkg X11BASE=/usr/X11R7 PKGMANDIR=man PKGINFODIR=info PKGGNUDIR=gnu/ MAKECONF=/dev/null OBJECT_FMT=ELF USETOOLS=no BSD_INSTALL_PROGRAM=/usr/bin/install\ -c\ -s\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_SCRIPT=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_LIB=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_DATA=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 644 BSD_INSTALL_MAN=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 644 BSD_INSTALL=/usr/bin/install BSD_INSTALL_PROGRAM_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_SCRIPT_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_LIB_DIR=/usr/bin/install\ -d\ -o\ root\ -
 g\ wheel\ -m\ 755 BSD_INSTALL_DATA_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_MAN_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 755 BSD_INSTALL_GAME=/usr/bin/install\ -c\ -s\ -o\ root\ -g\ wheel\ -m\ 2555 BSD_INSTALL_GAME_DATA=/usr/bin/install\ -c\ -o\ root\ -g\ wheel\ -m\ 664 BSD_INSTALL_GAME_DIR=/usr/bin/install\ -d\ -o\ root\ -g\ wheel\ -m\ 775 INSTALL_INFO= MAKEINFO=/work/pkgobj/textproc/py-expat/work/.tools/bin/makeinfo FLEX= BISON= PKG_CONFIG= PKG_CONFIG_LIBDIR=/work/pkgobj/textproc/py-expat/work/.buildlink/lib/pkgconfig:/work/pkgobj/textproc/py-expat/work/.buildlink/share/pkgconfig PKG_CONFIG_LOG=/work/pkgobj/textproc/py-expat/work/.pkg-config.log PKG_CONFIG_PATH= CWRAPPERS_CONFIG_DIR=/work/pkgobj/textproc/py-expat/work/.cwrapper/config /usr/pkg/bin/python3.6  setup.py  build )
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007d8fda790800 (most recent call first):
[1]   Abort trap (core dumped) (cd /work/pkgobj...
*** Error code 134

Stop.
make[1]: stopped in /usr/pkgsrc/textproc/py-expat
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x0000778df480e800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x0000747a424c6800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007788b9c17800 (most recent call first):
[1]   Abort trap (core dumped) /usr/pkg/bin/pyt...
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/textproc/py-expat


>How-To-Repeat:

cd /usr/pkgsrc/textproc/py-expat
(sleep 10; make) 2>&1 > /tmp/pkg.log &
^D

and from another session: tail -f /tmp/pkg.log

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53229: textproc/py-expat does not build w/o terminal session
Date: Sun, 29 Apr 2018 12:17:59 +0200

 https://bugs.python.org/issue33384

From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53229: textproc/py-expat does not build w/o terminal session
Date: Sat, 19 May 2018 17:25:15 +0200

 Hello Martin,

 Martin Husemann writes:
 >
 >  https://bugs.python.org/issue33384
 >  

 JFTR (and to include a possible patch for lang/python36!), it seems
 that also NetBSD is affected by bpo-30225
 (<https://bugs.python.org/issue30225>).

 Extracting is_valid_fd() (from Python/pylifecycle.c) in an
 is_valid_fd.c to ease the reproduction (in python-3.6.5 USE_FSTAT
 logic is only honored by __APPLE__ and dup(2) is used on all the
 the other platforms):

  | % cat is_valid_fd.c
  | #include <stdio.h>
  | #include <sys/stat.h>
  | #include <unistd.h>
  | 
  | /* Check if a file descriptor is valid or not.
  |    Return 0 if the file descriptor is invalid, return
  |    non-zero otherwise. */
  | static int
  | is_valid_fd(int fd)
  | {
  | #ifdef USE_FSTAT 
  |     /* bpo-30225: On macOS Tiger, when stdout is redirected
  |        to a pipe and the other side of the pipe is closed,
  |        dup(1) succeed, whereas fstat(1, &st) fails with EBADF.
  |        Prefer fstat() over dup() to detect such error. */
  |     struct stat st;
  |     return (fstat(fd, &st) == 0);
  | #else
  |     int fd2;
  |     if (fd < 0)
  |         return 0;
  |     /* Prefer dup() over fstat(). fstat() can require
  |        input/output whereas dup() doesn't, there is a low
  |        risk of EMFILE/ENFILE at Python startup. */
  |     fd2 = dup(fd);
  |     if (fd2 >= 0)
  |         close(fd2);
  |     return fd2 >= 0;
  | #endif
  | }
  | 
  | 
  | int
  | main(void)
  | {
  | 
  |     printf("0: %d\n", is_valid_fd(0));
  |     printf("1: %d\n", is_valid_fd(1));
  |     printf("2: %d\n", is_valid_fd(2));
  | 
  |     return 0;
  | }

 We can see (this is on NetBSD/amd64 8.99.15) that using dup(2):

  | % cc -o ivf is_valid_fd.c
  | % sleep 5 && ./ivf > /tmp/log & exit
  | [... the terminal is closed via ^D ...]
  | % cat /tmp/log
  | 0: 1
  | 1: 1
  | 2: 1

 ...and using fstat(2):

  | % cc -DUSE_FSTAT -o ivf is_valid_fd.c
  | % sleep 5 && ./ivf > /tmp/log & exit
  | [... the terminal is closed via ^D ...]
  | % cat /tmp/log
  | 0: 0
  | 1: 1
  | 2: 0

 The attached patch seems to fix that problem:

  <https://www.NetBSD.org/~leot/pkgsrc-patches/python36-3.6.5-bpo-33384.patch>

State-Changed-From-To: open->feedback
State-Changed-By: leot@NetBSD.org
State-Changed-When: Sat, 19 May 2018 15:35:59 +0000
State-Changed-Why:
Possible patch shared (seems to do the trick but I am not
super-confident about that)


From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53229: textproc/py-expat does not build w/o terminal session
Date: Mon, 21 May 2018 13:13:24 +0200

 And for completeness here the behaviours of just dup(2) and fstat(2)
 (please note that they can be safely ignored, but if you're
 curious...):

  | % cat sleep-and-dup.c
  | #include <errno.h>
  | #include <stdio.h>
  | #include <string.h>
  | #include <unistd.h>
  | =

  | =

  | int
  | main(void)
  | {
  | 	int fd;
  | =

  | 	if ((fd =3D dup(STDIN_FILENO)) !=3D -1)
  | 		printf("Before: %d\n", fd);
  | 	else
  | 		printf("%s\n", strerror(errno));
  | 	sleep(5);
  | 	if ((fd =3D dup(STDIN_FILENO)) !=3D -1)
  | 		printf("After: %d\n", fd);
  | 	else
  | 		printf("%s\n", strerror(errno));
  | 	return 0;
  | }
  | % cat sleep-and-fstat.c
  | #include <errno.h>
  | #include <sys/stat.h>
  | #include <stdio.h>
  | #include <string.h>
  | #include <unistd.h>
  | =

  | =

  | int
  | main(void)
  | {
  | 	struct stat st;
  | =

  | 	if (fstat(STDIN_FILENO, &st) !=3D -1)
  | 		printf("Before: %d\n", fstat(STDIN_FILENO, &st));
  | 	else
  | 		printf("%s\n", strerror(errno));
  | 	sleep(5);
  | 	if (fstat(STDIN_FILENO, &st) !=3D -1)
  | 		printf("Before: %d\n", fstat(STDIN_FILENO, &st));
  | 	else
  | 		printf("%s\n", strerror(errno));
  | 	return 0;
  | }
  | % cc sleep-and-dup.c -o dup
  | % cc sleep-and-fstat.c -o fstat
  | % ( ./dup > dup.log & ) && sleep 1 && exit
  | [... the terminal is closed ...]
  | % ( ./fstat > fstat.log & ) && sleep 1 && exit
  | [... the terminal is closed ...]
  | % cat dup.log
  | Before: 3
  | After: 4
  | % cat fstat.log
  | Before: 0
  | Bad file descriptor

 And according both 1003.1-2004 and 1003.1-2008, respectively for
 dup[0][1] in the ERRORS section we can read:

 > The dup() function shall fail if:
 > =

 > [EBADF]
 >     The fildes [oldfd in dup(2)] pargument is not a valid open file desc=
 riptor.
 > [...]

 In dup(2) regarding EBADF we have `oldfd is not a valid active descriptor'=
 .

 For fstat[2][3]:

 > The fstat() function shall fail if:
 > =

 > [EBADF]
 >     The fildes argument is not a valid file descriptor.
 > [...]

 In fstat(2) regarding EBADF we have `fd is not a valid open file descripto=
 r'.


 (So I guess that in the example above stdin is a valid /active/
 descriptor, while it is not a valid /open/ file descriptor!)


 [0]: <http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html>
 [1]: <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html>
 [2]: <http://pubs.opengroup.org/onlinepubs/009695399/functions/fstat.html>
 [3]: <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html=
 >

Responsible-Changed-From-To: pkg-manager->leot
Responsible-Changed-By: leot@NetBSD.org
Responsible-Changed-When: Sun, 03 Jun 2018 20:11:21 +0000
Responsible-Changed-Why:
Take


State-Changed-From-To: feedback->analyzed
State-Changed-By: leot@NetBSD.org
State-Changed-When: Tue, 09 Apr 2019 17:10:54 +0000
State-Changed-Why:
Problem analyzed, patch fixes the problem but not committed
because it would be nice if anyone more familiar with dup, fstat
semantics and standards can confirm that's actually ok!


State-Changed-From-To: analyzed->feedback
State-Changed-By: adam@NetBSD.org
State-Changed-When: Tue, 09 Apr 2019 18:50:43 +0000
State-Changed-Why:
The patch has been applied to Python 3.5, 3.6, and 3.7.


From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/53229 (textproc/py-expat does not build w/o terminal session)
Date: Tue, 09 Apr 2019 21:20:34 +0200

 adam@NetBSD.org writes:
 > [...]
 > State-Changed-From-To: analyzed->feedback
 > State-Changed-By: adam@NetBSD.org
 > State-Changed-When: Tue, 09 Apr 2019 18:50:43 +0000
 > State-Changed-Why:
 > The patch has been applied to Python 3.5, 3.6, and 3.7.
 > [...]

 JFTR, I think that also Python 3.4 needs that.

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/53229 (textproc/py-expat does not build w/o terminal session)
Date: Wed, 10 Apr 2019 03:24:14 +0700

     Date:        Tue,  9 Apr 2019 17:10:55 +0000 (UTC)
     From:        leot@NetBSD.org
     Message-ID:  <20190409171055.253647A1DC@mollari.NetBSD.org>

   | Problem analyzed, patch fixes the problem but not committed
   | because it would be nice if anyone more familiar with dup, fstat
   | semantics and standards can confirm that's actually ok!

 The simple answer to that is that it is obviously OK to use any
 technique you like (which works) to test if an fd is valid or not.
 So, the patch seems to be fine (switching NetBSD to use fstat() rather
 that dup()).

 On the broader question of whether the way NetBSD treats revoked terminals
 is POSIX compatible or not, from a quick glance at things, I'd say not.
 (However it is how BSD has done it for a long time, and I will ask on the
 austin group list for opinions from others).

 But POSIX XBD (basic definitions) section 11.1.3 ("The Controlling Terminal")
 says:

 	When a controlling process terminates, the controlling terminal
 	is dissociated from the current session, allowing it to be
 	acquired by a new session leader.

 That's what happens when the login shell exits.

 	Subsequent access to the terminal by other processes in the earlier
 	session may be denied, with attempts to access the terminal treated
 	as if a modem disconnect had been sensed.

 And this is what we are more or less achieving by the revoke, or
 it is with the same objective.


 And then, in XBD 11.1.10 ("Modem Diosconnect")

 	If a modem disconnect is detected by the terminal interface for
 	a controlling terminal, and if CLOCAL is not set in the c_cflag
 	field for the terminal (see Section 11.2.4, on page 209), the
 	SIGHUP signal shall be sent to the controlling process for which
 	the terminal is the controlling terminal. Unless other arrangements
 	have been made, this shall cause the controlling process to
 	terminate (see exit( )).

 That part is it is not really relevant, the background processing setup
 includes ignoring SIGHUP.  So here the state of CLOCAL is irrelevant
 (which is what would be wanted anyway.)

 	Any subsequent read from the terminal device shall return the
 	value of zero, indicating end-of-file; see read( ). Thus, processes
 	that read a terminal file and test for end-of-file can terminate
 	appropriately after a disconnect. If the EIO condition as specified
 	in read( ) also exists, it is unspecified whether on EOF condition
 	or [EIO] is returned. Any subsequent write( ) to the terminal device
 	shall return -1, with errno set to [EIO], until the device is closed.

 But that suggests that returning EBADF for a revoked terminal is not the
 POSIX specified approach, the fd should remain valid, and simply be unable
 to perform any I/O.   (Since ioctl() is not a POSIX interface, what happens
 with attempts to do that is clearly not specified.    However some operations
 that are typically implemented using ioctl() are specified, and those make
 no mention of returning an error for a terminal after a "modem disconnect".)

 From that I would suspect that both dup() and fstat() should continue to
 work on a revoked terminal (no errors) and that a later I/O request should
 fail (what this would do to python I have no idea, as by changing the
 dup() to fstat() for NetBSD suggests that the error is wanted, which if I
 am correct about posix, should not be generated from either.   Of course,
 this might only matter if some later call generates EBADF, and EIO or EOF
 might be treated differently.

 And as an aside, I don't know about MacOS, but on NetBSD, fcntl(F_GETFL)
 would be a cheaper (cheaper even than dup, as no close() is needed) way to
 test whether the fd is valid or not.   When EBADF is to be returned, all
 of them are equally cheap, but when there is no error, fstat() copies out
 a bunch of unwanted data, dup() returns an fd that needs to be closed, and
 fcntl(F_FETFL) simply returns an int which is easily ignored.

 kre

 I will append more to this PR if any meaningful response comes from the
 austin group.

State-Changed-From-To: feedback->closed
State-Changed-By: leot@NetBSD.org
State-Changed-When: Sun, 05 May 2019 09:46:00 +0000
State-Changed-Why:
Running:

 (sleep 10; python3.7 -c 'import sys' >/tmp/log 2>&1) & exit

and then exiting the parent shell now works.

This was addressed via:
 cvs rdiff -u -r1.19 -r1.20 pkgsrc/lang/python35/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/lang/python35/patches/patch-Python_pylifecycle.c
 cvs rdiff -u -r1.24 -r1.25 pkgsrc/lang/python36/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/lang/python36/patches/patch-Python_pylifecycle.c
 cvs rdiff -u -r1.7 -r1.8 pkgsrc/lang/python37/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/lang/python37/patches/patch-Python_pylifecycle.c

Thanks Martin for the PR, Adam for committing the patch and
Robert for further analysis and discussion with the austing group!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.