From phk@critter.freebsd.dk Fri Jul 22 15:53:08 2005 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2E8316A41F for ; Fri, 22 Jul 2005 15:53:08 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D79343D46 for ; Fri, 22 Jul 2005 15:52:58 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (0x535c0e2a.sgnxx1.adsl-dhcp.tele.dk [83.92.14.42]) by pasmtp.tele.dk (Postfix) with ESMTP id 134261EC329 for ; Fri, 22 Jul 2005 17:52:56 +0200 (CEST) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.4/8.13.4) with ESMTP id j6MFqriN052024 for ; Fri, 22 Jul 2005 17:52:53 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.13.4/8.13.4/Submit) id j6MFqq0D052023; Fri, 22 Jul 2005 17:52:52 +0200 (CEST) (envelope-from phk) Message-Id: <200507221552.j6MFqq0D052023@critter.freebsd.dk> Date: Fri, 22 Jul 2005 17:52:52 +0200 (CEST) From: Poul-Henning Kamp Reply-To: Poul-Henning Kamp To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: popen() doesn't work in static threaded programs. X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 83914 >Category: threads >Synopsis: [libc] popen() doesn't work in static threaded programs. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-threads >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jul 22 16:00:33 GMT 2005 >Closed-Date: Sun May 02 21:12:17 UTC 2010 >Last-Modified: Sun May 02 21:12:17 UTC 2010 >Originator: Poul-Henning Kamp >Release: FreeBSD 7.0-CURRENT i386 >Organization: >Environment: System: FreeBSD critter.freebsd.dk 7.0-CURRENT FreeBSD 7.0-CURRENT #2: Sun Jul 17 19:18:31 CEST 2005 root@critter.freebsd.dk:/freebsd/src/sys/i386/compile/CRITTER i386 >Description: popen() does not work if a threaded program is linked static but it works fine for a dynamic binary. >How-To-Repeat: Attached a source file & Makefile. run "make test" to see difference. begin 664 Makefile M"@I04D]'"3T)8G5G,C`P-3`W,C(*"DQ$041$"3T)+6QP=&AR96%D"@I.3U]- M04X)/0EN;PH*+FEF(%-4051)0PI#1DQ!1U,)*ST)+7-T871I8PHN96YD:68* M"BYI;F-L=61E(#QBTU!2T5](&-L96%N"@DD>TU!2T5] M"@DN+R1[4%)/1WT*"0H)0&5C:&\@(B,C(R,C(%-4051)0R!"24Y!4ED@(R,C M(R,B"@DD>TU!2T5](&-L96%N"@DD>TU!2T5](%-4051)0SUY97,*"2XO)'M0 %4D]'?0H` ` end begin 664 bug20050722.c M(VEN8VQU9&4@/'-T9&EO+F@^"B-I;F-L=61E(#QEF5O9B!B=68L(&8I M*0H)"7!R:6YT9B@B)7,B+"!B=68I.PH):2`]('!C;&]S92AF*3L*"6EF("AI M*0H)"7=APH*"7!T:')E861?="!T<#L*"@EI9B`H<'1H M5]T:')E860L($Y53$PI*2`*"0EE MFix: >Release-Note: >Audit-Trail: From: David Xu To: bug-followup@FreeBSD.org, phk@critter.freebsd.dk Cc: Subject: Re: bin/83914: [libc] popen() doesn't work in static threaded programs. Date: Fri, 03 Feb 2006 13:45:26 +0800 if you compile it with libthr in static binary case, it still works, but, I don't know why it will not work with libpthread, strange. David Xu Responsible-Changed-From-To: freebsd-bugs->freebsd-threads Responsible-Changed-By: davidxu Responsible-Changed-When: Mon Feb 6 11:57:00 UTC 2006 Responsible-Changed-Why: This might be a thread library problem. http://www.freebsd.org/cgi/query-pr.cgi?pr=83914 From: "Andrey Sverdlichenko" To: bug-followup@freebsd.org, phk@critter.freebsd.dk Cc: Subject: Re: threads/83914: [libc] popen() doesn't work in static threaded programs. Date: Thu, 12 Jul 2007 19:41:27 +0400 Same problem exists in FreeBSD 6.2-RELEASE. Looks like fork() makes a call to _kse_single_thread(), which set curthread->attr.flags |=3D PTHREAD_SCOPE_SYSTEM But in _execve() this flag is gone, so instead of __sys_execve() call to kse_thr_interrupt() is made and in-kernel check for P_SA fails. From: "Andrey Sverdlichenko" To: bug-followup@freebsd.org, phk@critter.freebsd.dk Cc: Subject: Re: threads/83914: [libc] popen() doesn't work in static threaded programs. Date: Fri, 13 Jul 2007 13:10:54 +0400 It's linking issue. In dynamically linked executable vfork() mapped to threaded library by weak_reference. In statically linked binary popen() calls vfork() from libc.a, but later calls _execve() from libpthread.a since it's not weak symbol. State-Changed-From-To: open->closed State-Changed-By: jilles State-Changed-When: Sun May 2 21:12:10 UTC 2010 State-Changed-Why: KSE is no longer developed, please use libthr which does not have this problem. http://www.freebsd.org/cgi/query-pr.cgi?pr=83914 >Unformatted: