From owner-freebsd-hackers Thu Feb 7 21:47: 8 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from alcatraz.iptelecom.net.ua (alcatraz.iptelecom.net.ua [212.9.224.15]) by hub.freebsd.org (Postfix) with ESMTP id 067CF37B421; Thu, 7 Feb 2002 21:46:54 -0800 (PST) Received: from ipcard.iptcom.net (ipcard.iptcom.net [212.9.224.5]) by alcatraz.iptelecom.net.ua (8.9.3/8.9.3) with ESMTP id HAA32528; Fri, 8 Feb 2002 07:46:49 +0200 (EET) (envelope-from sobomax@FreeBSD.org) Received: from h12.229.dialup.iptcom.net (h12.229.dialup.iptcom.net [212.9.229.12]) by ipcard.iptcom.net (8.9.3/8.9.3) with ESMTP id HAA67834; Fri, 8 Feb 2002 07:46:45 +0200 (EET) (envelope-from sobomax@FreeBSD.org) Subject: Linking libc before libc_r into application causes weird problems From: Maxim Sobolev To: jdp@FreeBSD.org, deischen@FreeBSD.org, jasone@FreeBSD.org, hackers@FreeBSD.org, jlemon@FreeBSD.org Content-Type: multipart/mixed; boundary="=-HwruOWPo7n3Nq8WN5HEs" Message-Id: <1013147180.73417.2.camel@notebook> Mime-Version: 1.0 X-Mailer: Evolution/1.0.2 Date: 08 Feb 2002 07:46:34 +0200 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --=-HwruOWPo7n3Nq8WN5HEs Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, When working on updating port of Ximian Evolution to the latest released version I have stuck to the problem - the new version of application just hanged on startup on my 5-CURRENT box. After lot of digging and debugging I found that the source of the problem is that the resulting application had libc linked in before libc_r, which caused waitpid() in the ORBit library just hang forever, even though child process died almost instantly (I see zombie in the ps(1) output). When program was relinked with -pthread flag, which seemingly forcing "right" order of libc/libc_r (libc_r first) the problem disappeared. Based on the problematic code in the ORBit I had prepared short testcase illustrating the problem and attaching it with this message. The problem could be exposed by compiling the test.c using the following command: $ cc test.c -o test -lc -lc_r When either of -lc or -lc_r is omitted, or their order is reversed the problem disappears. The problem doesn't exist on 4-STABLE. Any ideas, comments and suggestions are welcome. Thanks! -Maxim --=-HwruOWPo7n3Nq8WN5HEs Content-Disposition: attachment; filename=test.c Content-Transfer-Encoding: quoted-printable Content-Type: text/x-c; charset=KOI8-R #include #include #include #include #include #include int main() { int childpid, exitstatus, itmp; sigset_t mask, omask; /* Block SIGCHLD so no one else can wait() on the child before we do. *= / sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigprocmask(SIG_BLOCK, &mask, &omask); childpid =3D fork(); if(!childpid) { int i; /* Do something useful */ sleep(1); _exit(0); } while ((itmp =3D waitpid(childpid, &exitstatus, 0)) =3D=3D -1 && errno = =3D=3D EINTR) continue; sigprocmask (SIG_SETMASK, &omask, NULL); exit(WEXITSTATUS(exitstatus)); } --=-HwruOWPo7n3Nq8WN5HEs-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message