From owner-freebsd-hackers@freebsd.org Thu Jan 3 01:21:15 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F17BC1437FC9 for ; Thu, 3 Jan 2019 01:21:14 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic306-22.consmr.mail.ne1.yahoo.com (sonic306-22.consmr.mail.ne1.yahoo.com [66.163.189.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 19DEA823D9 for ; Thu, 3 Jan 2019 01:21:13 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: jqRshcYVM1nrDwOHBAxh0WajLYdNdgSiA1M5z5BblqWvmz2u2nR76lR0uetmNP5 4CkyBHh7pnFT9ckZyyBvTCfbpxPOc4Nna02_rGJrbPyxePvM2BVkX1xOE6bnIDrFAVd1oKy_2AbM 1H932YJQmeSi1zTEanA8jAfoILvZhBZJY.EiGO8bT8VGwK7vn2ZUNktSYUee_m03ZvUYns3eTI2X qyw0zmqMnRvC5W8hSrYq8iHz5pD5EO4lW0bme1.ALUTDV20q1UqcbDJwP6D7r0MVuKlY3ViCdcIK tE5X_wzcxTjGSfeTDT24o.pEwCJrZxhnspsu7ycKMh7eJ1hfUEYJ_tgH7C34IxRoI9VddF0oLx51 F8Rs1sn2Nsv16GXSiyK39uDMtYaCgZkLN3UBQ6GR2jLezjaFcn4L_QocVQTC7ytxLP_BLRkCe3Yy X3E4y2gl9OtqUUHjCRXAdPHr4O9vQD0f5XEpnjqzPy0bWeuFKfJBEUgTXCe6VTLb_ABjUzKE46vp 3O5N7whgzo.u3UoFQUYvZhXh3v5bMSVrEU8lI77X12CDCq6N8AW9xqREggbMeGr_00wjfyHOTAqZ CytuL9U6AQitQ_y5EXJO7JtKyvM1S.iM75kog6tKdbqNlqG3Tg_mU14YTPInTXLlKlGvhFMwNhvN YyRi7H8XDjz0z3O5JBAct4KirIytTFeWDrZn1UTn1A1eDgrdDS7Pg6LcQyueJw6BYx6KCeWdbhYx xEy_iZJEVdrZs5aG0NQviplqlp6YfKEa.WK.iSkXpvqLUoRC5dcsynObTfzjIWKGO7xBlU8vTYnR ckYm2SMZqtgCO3W_V3QVauwiazkTyn5OpaMdVv3vQ81qcMdTEyfDLRx_8Zz_5PTUs3_FT71Bw0kY QH_6ZKyvA3SN4cJciCQG6nkWnwbNGjV1l4Di09X1nGtSGVIU84rs5dyIjmJ4YCb_gCGN_ho6M7cT WFR62ocpBvZ4RiflDB1tvEUWulRvkDXL_jwSw7YBb95xASMXvp6EApP7a7hp1Z4lmUfgTLQ7IKDx nhlnbFdiqjmgo9lBuVxp5ZGOoA5hxAX99r2zf9wGZW.BtEPs7pDOxM__O3G0i Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Jan 2019 01:21:06 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.109]) ([67.170.167.181]) by smtp404.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID d2f90f80428317f6f117208ec5143403 for ; Thu, 03 Jan 2019 01:21:05 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Code questions tied to a qemu-aarch64-static hang-up that I observe during a amd64->aarch64 poudriere-devel based bulk cross-build of some ports Message-Id: Date: Wed, 2 Jan 2019 17:21:03 -0800 To: freebsd-hackers Hackers X-Mailer: Apple Mail (2.3445.102.3) X-Rspamd-Queue-Id: 19DEA823D9 X-Spamd-Bar: / X-Spamd-Result: default: False [-0.81 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DKIM_TRACE(0.00)[yahoo.com:+]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; NEURAL_HAM_SHORT(-0.16)[-0.159,0]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.60)[-0.597,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.54)[-0.536,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(0.99)[ip: (3.04), ipnet: 66.163.184.0/21(1.11), asn: 36646(0.88), country: US(-0.08)]; RCVD_IN_DNSWL_NONE(0.00)[84.189.163.66.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:21:15 -0000 The following code is from where I see a hang-up in qemu-aarch64-static: /* select(2) */ static inline abi_long do_freebsd_select(CPUArchState *env, int n, abi_ulong rfd_addr, abi_ulong wfd_addr, abi_ulong efd_addr, abi_ulong target_tv_addr) { . . . (omitted material . . . sigfillset(&mask); sigprocmask(SIG_BLOCK, &mask, &omask); if (ts->signal_pending) { . . . (omitted) . . . } else { ret =3D get_errno(pselect(n, rfds_ptr, wfds_ptr, efds_ptr, = ts_ptr, &omask)); sigprocmask(SIG_SETMASK, &omask, NULL); } So more directly for the path taken:, with some comments added that are tied to my question: // signals might not be blocked here sigfillset(&mask); sigprocmask(SIG_BLOCK, &mask, &omask); // so signals are blocked // but the below reneables them during waitin in pselect // (if they were not blocked before the sigprocmask call). ret =3D get_errno(pselect(n, rfds_ptr, wfds_ptr, efds_ptr, ts_ptr, &omask)); // signals are again blocked during parts of pselect // and here after returning. sigprocmask(SIG_SETMASK, &omask, NULL); // signals are no longer blocked Question Is there a reason for this code structure to be used? If so, what is it? I've another qeuestion based on what gdb reports and man pages say. (I extracted material from records of multiple gdb sessions.) (gdb) bt #0 _pselect () at _pselect.S:3 #1 0x00000000601da57f in __thr_pselect (count=3D12, = rfds=3D0x7ffffffe3650, wfds=3D0x0, efds=3D0x0, timo=3D0x0, = mask=3D0x7ffffffe3600) at /usr/src/lib/libthr/thread/thr_syscalls.c:378 #2 0x000000006004928d in do_freebsd_select (env=3D0x860edfb18, = n=3D, rfd_addr=3D140736934698744, wfd_addr=3D, efd_addr=3D0, target_tv_addr=3D0) at = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/freebsd/os-time.h:468 #3 do_freebsd_syscall (cpu_env=3D0x860edfb18, num=3D93, arg1=3D12, = arg2=3D140736934698744, arg3=3D0, arg4=3D0, arg5=3D0, arg6=3D274914043516,= arg7=3D274913946564, arg8=3D6579811) at = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/syscall.c:1106 #4 0x000000006003903c in target_cpu_loop (env=3D0x860edfb18) at = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/aarch64/target_arch_cpu.h:100 #5 0x0000000060038e09 in cpu_loop (env=3D0xc) at = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/main.c:121 #6 0x0000000060039ecb in main (argc=3D, = argv=3D0x7fffffffd360) at = /wrkdirs/usr/ports/emulators/qemu-user-static/work/qemu-bsd-user-4ef7d07/b= sd-user/main.c:513 Note the use of __thr_pselect . But I see in gdb's disass: 0x00000000600490ab <+33227>: callq 0x602b3b20 0x00000000600490b0 <+33232>: cmpl $0x0,0x19440(%r12) 0x00000000600490b9 <+33241>: je 0x60049262 = . . . 0x0000000060049262 <+33666>: mov -0x2f8(%rbp),%rsi 0x0000000060049269 <+33673>: mov -0x2f0(%rbp),%rdx 0x0000000060049270 <+33680>: mov -0x2e8(%rbp),%rcx 0x0000000060049277 <+33687>: lea -0x2e0(%rbp),%r9 0x000000006004927e <+33694>: mov -0x2b8(%rbp),%rdi 0x0000000060049285 <+33701>: mov %r14,%r8 0x0000000060049288 <+33704>: callq 0x601e1cb0 Yet:=20 = https://www.freebsd.org/cgi/man.cgi?query=3Dsigprocmask&apropos=3D0&sektio= n=3D2&manpath=3DFreeBSD+13-current&arch=3Ddefault&format=3Dhtml reports the following: QUOTE In threaded applications, pthread_sigmask(3) must be used instead of = sigprocmask(). END QUOTE But gdb shows use of 2 threads overall: (gdb) info threads Id Target Id Frame=20 * 1 LWP 100804 of process 89695 _pselect () at _pselect.S:3 2 LWP 101548 of process 89695 _umtx_op_err () at = /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37 So is the apparent use of sigprocmask valid in this context? For reference for where the hang-up happens for: configure:6844: checking whether // is distinct from / The result is: root 87913 0.0 0.0 12920 3668 0 I 13:29 0:00.06 | = | `-- sh: poudriere[FBSDFSSDjailCortexA57-default][01]: = build_pkg (texinfo-6.5_1,1) (sh) root 88869 0.0 0.0 12920 3660 0 I 13:29 0:00.00 | = | `-- sh: poudriere[FBSDFSSDjailCortexA57-default][01]: = build_pkg (texinfo-6.5_1,1) (sh) root 88870 0.0 0.0 10412 1848 0 IJ 13:29 0:00.01 | = | `-- /usr/bin/make -C /usr/ports/print/texinfo configure root 88974 0.0 0.0 10272 1812 0 IJ 13:30 0:00.00 | = | `-- /bin/sh -e -c (cd = /wrkdirs/usr/ports/print/texinfo/work/texinfo-6.5 && = _LATE_CONFIGURE_ARGS=3D"" ; if [=20 root 89283 0.0 0.0 11160 2108 0 IJ 13:30 0:00.10 | = | `-- /bin/sh ./configure --enable-nls = --prefix=3D/usr/local --localstatedir=3D/var --mandir=3D/usr/local/man = --di root 89692 0.0 0.0 227368 14504 0 IJ 13:30 0:00.03 | = | `-- /usr/local/bin/qemu-aarch64-static wc = //dev/null root 89694 0.0 0.0 227424 14596 0 IJ 13:30 0:00.01 | = | `-- /usr/local/bin/qemu-aarch64-static wc = //dev/null root 89695 0.0 0.0 227584 14720 0 IJ 13:30 0:00.01 | = | `-- wc: zygote (qemu-aarch64-static) wc (via qemu-aarch64-static) gets stuck in what apparently was a select = request that turned into a pselect use. (do_freebsd_pselect was not called.) =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)